diff --git a/services/web/app/coffee/Features/Exports/ExportsController.coffee b/services/web/app/coffee/Features/Exports/ExportsController.coffee index ea82cf6a04..fc339f9957 100644 --- a/services/web/app/coffee/Features/Exports/ExportsController.coffee +++ b/services/web/app/coffee/Features/Exports/ExportsController.coffee @@ -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 diff --git a/services/web/app/coffee/Features/Exports/ExportsHandler.coffee b/services/web/app/coffee/Features/Exports/ExportsHandler.coffee index 885f063c8b..18644a66e6 100644 --- a/services/web/app/coffee/Features/Exports/ExportsHandler.coffee +++ b/services/web/app/coffee/Features/Exports/ExportsHandler.coffee @@ -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? diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 578ff0ceb7..b9f48805c4 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -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 diff --git a/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee b/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee index edd1ce127a..f766feb6dd 100644 --- a/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee +++ b/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee @@ -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()