2018-02-08 12:01:06 +01:00
|
|
|
'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);
|
2018-02-08 12:01:06 +01:00
|
|
|
|
|
|
|
// Send 200 `ok`
|
2018-02-19 14:26:20 +01:00
|
|
|
ctx.send(files.map((file) => {
|
|
|
|
return {
|
|
|
|
url: `/${file.key}`
|
|
|
|
};
|
|
|
|
}));
|
2018-02-08 12:01:06 +01:00
|
|
|
}
|
|
|
|
};
|