Skip to content

Instantly share code, notes, and snippets.

@MattieBelt
Created June 24, 2021 15:30
Show Gist options
  • Save MattieBelt/189b1aae902bf08a83c69f5433c733f3 to your computer and use it in GitHub Desktop.
Save MattieBelt/189b1aae902bf08a83c69f5433c733f3 to your computer and use it in GitHub Desktop.
const { sanitizeEntity } = require('strapi-utils');
module.exports = {
async upload(ctx) {
const {
request: { files: { files } = {} },
} = ctx;
const uploadedFiles = await strapi.plugins.upload.services.upload.upload({
data: {},
files,
});
const entity = await strapi.plugins['users-permissions'].services.user.edit({ id: ctx.state.user.id }, { image: uploadedFiles[0].id });
return sanitizeEntity(entity, { model: strapi.query('user', 'users-permissions').model });
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment