diff --git a/lib/api/storage.js b/lib/api/storage.js index a704fde6..32d7e76c 100644 --- a/lib/api/storage.js +++ b/lib/api/storage.js @@ -377,11 +377,35 @@ module.exports = (db, server, storageHandler) => { ); server.get( - { name: 'storagefile', path: '/users/:user/storage/:file' }, + { + name: 'storagefile', + path: '/users/:user/storage/:file', + tags: ['Storage'], + summary: 'Download File', + description: 'This method returns stored file contents in binary form', + responseType: 'application/octet-stream', + validationObjs: { + requestBody: {}, + queryParams: {}, + pathParams: { + user: userId, + file: Joi.string().hex().lowercase().length(24).required().description('ID of the File') + }, + response: { + 200: { + description: 'Success', + model: Joi.binary() + } + } + } + }, tools.responseWrapper(async (req, res) => { - const schema = Joi.object().keys({ - user: Joi.string().hex().lowercase().length(24).required(), - file: Joi.string().hex().lowercase().length(24).required() + const { requestBody, queryParams, pathParams } = req.route.spec.validationObjs; + + const schema = Joi.object({ + ...requestBody, + ...queryParams, + ...pathParams }); const result = schema.validate(req.params, {