allow proxying of template images though filestore

This commit is contained in:
Henry Oswald 2015-04-09 17:14:47 +01:00
parent eb89337ada
commit b3432f016c
3 changed files with 4 additions and 3 deletions

View file

@ -74,6 +74,7 @@ app.put "/project/:project_id/file/:file_id", keyBuilder.userFileKey, fileContro
app.del "/project/:project_id/file/:file_id", keyBuilder.userFileKey, fileController.deleteFile
app.get "/template/:template_id/v/:version/:format", keyBuilder.templateFileKey, fileController.getFile
app.get "/template/:template_id/v/:version/:format/:sub_type", keyBuilder.templateFileKey, fileController.getFile
app.post "/template/:template_id/v/:version/:format", keyBuilder.templateFileKey, fileController.insertFile
app.get "/heapdump", (req, res)->

View file

@ -40,7 +40,7 @@ module.exports =
args = "nice convert -flatten -background white -density 300 -define pdf:fit-page=#{width} #{sourcePath} -resize #{width} #{destPath}"
exec args, childProcessOpts, (err, stdout, stderr)->
if err?
logger.err err:err, stderr:stderr, sourcePath:sourcePath, "something went wrong converting file to preview"
logger.err err:err, stderr:stderr, sourcePath:sourcePath, "something went wrong converting file to thumbnail"
else
logger.log sourcePath:sourcePath, destPath:destPath, "finished thumbnailing file"
callback(err, destPath)

View file

@ -24,8 +24,8 @@ module.exports =
next()
templateFileKey: (req, res, next)->
{template_id, format, version} = req.params
req.key = "#{template_id}/v/#{version}/#{format}"
{template_id, format, version, sub_type} = req.params
req.key = "#{template_id}/v/#{version}/#{format}/#{sub_type}"
req.bucket = settings.filestore.stores.template_files
req.version = version
opts = req.query