Merge pull request #918 from lucaperret/feat/findOne-upload

Add find one file endpoint
This commit is contained in:
Jim LAURIE 2018-04-10 10:24:52 +02:00 committed by GitHub
commit 6934661845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

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

View File

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