mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
allow fetching of export zips
This commit is contained in:
parent
3cf060dbac
commit
3532a29d50
3 changed files with 24 additions and 0 deletions
|
@ -37,3 +37,10 @@ module.exports =
|
||||||
status_detail: parsed_export.status_detail
|
status_detail: parsed_export.status_detail
|
||||||
}
|
}
|
||||||
res.send export_json: json
|
res.send export_json: json
|
||||||
|
|
||||||
|
exportZip: (req, res) ->
|
||||||
|
{export_id} = req.params
|
||||||
|
ExportsHandler.fetchZip export_id, (err, export_zip_url) ->
|
||||||
|
return err if err?
|
||||||
|
|
||||||
|
res.redirect export_zip_url
|
||||||
|
|
|
@ -115,3 +115,19 @@ module.exports = ExportsHandler = self =
|
||||||
err = new Error("v1 export returned a failure status code: #{res.statusCode}")
|
err = new Error("v1 export returned a failure status code: #{res.statusCode}")
|
||||||
logger.err err:err, export:export_id, "v1 export returned failure status code: #{res.statusCode}"
|
logger.err err:err, export:export_id, "v1 export returned failure status code: #{res.statusCode}"
|
||||||
callback err
|
callback err
|
||||||
|
|
||||||
|
fetchZip: (export_id, callback=(err, zip_url) ->) ->
|
||||||
|
console.log("#{settings.apis.v1.url}/api/v1/sharelatex/exports/#{export_id}/zip_url")
|
||||||
|
request.get {
|
||||||
|
url: "#{settings.apis.v1.url}/api/v1/sharelatex/exports/#{export_id}/zip_url"
|
||||||
|
auth: {user: settings.apis.v1.user, pass: settings.apis.v1.pass }
|
||||||
|
}, (err, res, body) ->
|
||||||
|
if err?
|
||||||
|
logger.err err:err, export:export_id, "error making request to v1 export"
|
||||||
|
callback err
|
||||||
|
else if 200 <= res.statusCode < 300
|
||||||
|
callback null, body
|
||||||
|
else
|
||||||
|
err = new Error("v1 export returned a failure status code: #{res.statusCode}")
|
||||||
|
logger.err err:err, export:export_id, "v1 export zip fetch returned failure status code: #{res.statusCode}"
|
||||||
|
callback err
|
||||||
|
|
|
@ -245,6 +245,7 @@ module.exports = class Router
|
||||||
|
|
||||||
webRouter.post '/project/:project_id/export/:brand_variation_id', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportProject
|
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', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportStatus
|
||||||
|
webRouter.get '/project/:project_id/export/:export_id/zip', AuthorizationMiddlewear.ensureUserCanAdminProject, ExportsController.exportZip
|
||||||
|
|
||||||
webRouter.get '/Project/:Project_id/download/zip', AuthorizationMiddlewear.ensureUserCanReadProject, ProjectDownloadsController.downloadProject
|
webRouter.get '/Project/:Project_id/download/zip', AuthorizationMiddlewear.ensureUserCanReadProject, ProjectDownloadsController.downloadProject
|
||||||
webRouter.get '/project/download/zip', AuthorizationMiddlewear.ensureUserCanReadMultipleProjects, ProjectDownloadsController.downloadMultipleProjects
|
webRouter.get '/project/download/zip', AuthorizationMiddlewear.ensureUserCanReadMultipleProjects, ProjectDownloadsController.downloadMultipleProjects
|
||||||
|
|
Loading…
Reference in a new issue