Skip to content

Commit

Permalink
added Download file api endpoint to api docs generation
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt committed Apr 22, 2024
1 parent bd9dcbf commit 10e30b1
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions lib/api/storage.js
Expand Up @@ -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, {
Expand Down

0 comments on commit 10e30b1

Please sign in to comment.