32 lines
523 B
JavaScript
Raw Normal View History

'use strict';
/**
* Upload.js controller
*
* @description: A set of functions called "actions" of the `upload` plugin.
*/
module.exports = {
/**
* Default action.
*
* @return {Object}
*/
index: async (ctx) => {
2018-02-19 14:26:20 +01:00
const Service = strapi.plugins['upload'].services.upload;
const files = await Service.getFiles(ctx.request.body.files);
await Service.upload(files);
// Send 200 `ok`
2018-02-19 14:26:20 +01:00
ctx.send(files.map((file) => {
return {
url: `/${file.key}`
};
}));
}
};