salix/back/methods/dms/downloadFile.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-03-24 16:34:23 +00:00
const checkRole = require('./checkRole');
const getfile = require('./getfile');
2019-05-01 16:49:39 +00:00
module.exports = Self => {
Self.remoteMethodCtx('downloadFile', {
2019-05-01 16:49:39 +00:00
description: 'Download a document',
accessType: 'READ',
accepts: [
{
arg: 'id',
type: 'Number',
2019-05-01 16:49:39 +00:00
description: 'The document id',
http: {source: 'path'}
}
],
returns: [
{
arg: 'body',
type: 'file',
root: true
}, {
arg: 'Content-Type',
type: 'String',
http: {target: 'header'}
}, {
arg: 'Content-Disposition',
type: 'String',
http: {target: 'header'}
}
],
http: {
path: `/:id/downloadFile`,
2019-05-01 16:49:39 +00:00
verb: 'GET'
}
});
Self.downloadFile = async function(ctx, id) {
2020-03-24 16:34:23 +00:00
await checkRole(ctx, id);
return await getfile(ctx, id);
2019-05-01 16:49:39 +00:00
};
};