mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
make the zip fetching endpoint for exports generic to either zips or pdfs
This commit is contained in:
parent
a35b3eea7f
commit
52859cdfaa
4 changed files with 10 additions and 10 deletions
|
@ -46,10 +46,11 @@ module.exports =
|
|||
}
|
||||
res.send export_json: json
|
||||
|
||||
exportZip: (req, res) ->
|
||||
{export_id} = req.params
|
||||
exportDownload: (req, res) ->
|
||||
{type, export_id} = req.params
|
||||
|
||||
AuthenticationController.getLoggedInUserId(req)
|
||||
ExportsHandler.fetchZip export_id, (err, export_zip_url) ->
|
||||
ExportsHandler.fetchDownload export_id, type, (err, export_file_url) ->
|
||||
return err if err?
|
||||
|
||||
res.redirect export_zip_url
|
||||
res.redirect export_file_url
|
||||
|
|
|
@ -122,10 +122,9 @@ module.exports = ExportsHandler = self =
|
|||
logger.err err:err, export:export_id, "v1 export returned failure status code: #{res.statusCode}"
|
||||
callback err
|
||||
|
||||
fetchZip: (export_id, callback=(err, zip_url) ->) ->
|
||||
console.log("#{settings.apis.v1.url}/api/v1/sharelatex/exports/#{export_id}/zip_url")
|
||||
fetchDownload: (export_id, type, callback=(err, file_url) ->) ->
|
||||
request.get {
|
||||
url: "#{settings.apis.v1.url}/api/v1/sharelatex/exports/#{export_id}/zip_url"
|
||||
url: "#{settings.apis.v1.url}/api/v1/sharelatex/exports/#{export_id}/#{type}_url"
|
||||
auth: {user: settings.apis.v1.user, pass: settings.apis.v1.pass }
|
||||
}, (err, res, body) ->
|
||||
if err?
|
||||
|
|
|
@ -247,7 +247,7 @@ module.exports = class Router
|
|||
|
||||
webRouter.post '/project/:project_id/export/:brand_variation_id', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportProject
|
||||
webRouter.get '/project/:project_id/export/:export_id', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportStatus
|
||||
webRouter.get '/project/:project_id/export/:export_id/zip', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportZip
|
||||
webRouter.get '/project/:project_id/export/:export_id/:type', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportDownload
|
||||
|
||||
webRouter.get '/Project/:Project_id/download/zip', AuthorizationMiddlewear.ensureUserCanReadProject, ProjectDownloadsController.downloadProject
|
||||
webRouter.get '/project/download/zip', AuthorizationMiddlewear.ensureUserCanReadMultipleProjects, ProjectDownloadsController.downloadMultipleProjects
|
||||
|
|
|
@ -301,7 +301,7 @@ describe 'ExportsHandler', ->
|
|||
@callback.calledWith(null, { body: @body })
|
||||
.should.equal true
|
||||
|
||||
describe 'fetchZip', ->
|
||||
describe 'fetchDownload', ->
|
||||
beforeEach (done) ->
|
||||
@settings.apis =
|
||||
v1:
|
||||
|
@ -316,7 +316,7 @@ describe 'ExportsHandler', ->
|
|||
describe "when all goes well", ->
|
||||
beforeEach (done) ->
|
||||
@stubRequest.get = @stubGet
|
||||
@ExportsHandler.fetchZip @export_id, (error, body) =>
|
||||
@ExportsHandler.fetchDownload @export_id, 'zip', (error, body) =>
|
||||
@callback(error, body)
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue