Route count uploads

This commit is contained in:
Jim Laurie 2018-02-19 19:54:45 +01:00
parent 9ef00e217d
commit 44ec9e9e02
3 changed files with 21 additions and 0 deletions

View File

@ -16,6 +16,14 @@
"policies": []
}
},
{
"method": "GET",
"path": "/files/count",
"handler": "Upload.count",
"config": {
"policies": []
}
},
{
"method": "DELETE",
"path": "/files/:_id",

View File

@ -44,6 +44,15 @@ module.exports = {
}));
},
count: async (ctx, next) => {
const data = await strapi.plugins['upload'].services.upload.count(ctx.query);
// Send 200 `ok`
ctx.send({
count: data
});
},
destroy: async (ctx, next) => {
const data = await strapi.plugins['upload'].services.upload.remove(ctx.params);

View File

@ -91,6 +91,10 @@ module.exports = {
return strapi.query('file', 'upload').find(strapi.utils.models.convertParams('file', params));
},
count: async (params, source) => {
return await strapi.query('file', 'upload').count();
},
remove: async params => {
const {url} = await strapi.plugins['upload'].services.upload.fetch(params);