mirror of
https://github.com/strapi/strapi.git
synced 2025-09-02 05:13:03 +00:00
Upgrade koa-body version to latest
This commit is contained in:
parent
a9c9fdbbec
commit
184490a07d
@ -10,6 +10,8 @@ const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
async upload(ctx) {
|
||||
const uploadService = strapi.plugins.upload.services.upload;
|
||||
|
||||
// Retrieve provider configuration.
|
||||
const config = await strapi
|
||||
.store({
|
||||
@ -30,8 +32,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Extract optional relational data.
|
||||
const { refId, ref, source, field, path } = ctx.request.body.fields || {};
|
||||
const { files = {} } = ctx.request.body.files || {};
|
||||
const { refId, ref, source, field, path } = ctx.request.body || {};
|
||||
const { files = {} } = ctx.request.files || {};
|
||||
|
||||
if (_.isEmpty(files)) {
|
||||
return ctx.badRequest(
|
||||
@ -43,9 +45,8 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Transform stream files to buffer
|
||||
const buffers = await strapi.plugins.upload.services.upload.bufferize(
|
||||
ctx.request.body.files.files
|
||||
);
|
||||
const buffers = await uploadService.bufferize(files);
|
||||
|
||||
const enhancedFiles = buffers.map(file => {
|
||||
if (file.size > config.sizeLimit) {
|
||||
return ctx.badRequest(
|
||||
@ -94,10 +95,7 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
const uploadedFiles = await strapi.plugins.upload.services.upload.upload(
|
||||
enhancedFiles,
|
||||
config
|
||||
);
|
||||
const uploadedFiles = await uploadService.upload(enhancedFiles, config);
|
||||
|
||||
// Send 200 `ok`
|
||||
ctx.send(
|
||||
|
@ -24,7 +24,7 @@
|
||||
"inquirer": "^6.2.1",
|
||||
"kcors": "^2.2.0",
|
||||
"koa": "^2.1.0",
|
||||
"koa-body": "^2.5.0",
|
||||
"koa-body": "^4.1.0",
|
||||
"koa-compose": "^4.0.0",
|
||||
"koa-compress": "^2.0.0",
|
||||
"koa-convert": "^1.2.0",
|
||||
|
17
yarn.lock
17
yarn.lock
@ -2235,6 +2235,14 @@
|
||||
"@types/express-serve-static-core" "*"
|
||||
"@types/serve-static" "*"
|
||||
|
||||
"@types/formidable@^1.0.31":
|
||||
version "1.0.31"
|
||||
resolved "https://registry.yarnpkg.com/@types/formidable/-/formidable-1.0.31.tgz#274f9dc2d0a1a9ce1feef48c24ca0859e7ec947b"
|
||||
integrity sha512-dIhM5t8lRP0oWe2HF8MuPvdd1TpPTjhDMAqemcq6oIZQCBQTovhBAdTQ5L5veJB4pdQChadmHuxtB0YzqvfU3Q==
|
||||
dependencies:
|
||||
"@types/events" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/glob@^7.1.1":
|
||||
version "7.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
|
||||
@ -10490,11 +10498,12 @@ knex@^0.19.0:
|
||||
uuid "^3.3.2"
|
||||
v8flags "^3.1.3"
|
||||
|
||||
koa-body@^2.5.0:
|
||||
version "2.6.0"
|
||||
resolved "https://registry.yarnpkg.com/koa-body/-/koa-body-2.6.0.tgz#8ed7a192a64a38df610a986342d1801855641a1d"
|
||||
integrity sha512-8i9ti3TRxelsnPUct0xY8toTFj5gTzGWW45ePBkT8fnzZP75y5woisVpziIdqcnqtt1lMNBD30p+tkiSC+NfjQ==
|
||||
koa-body@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/koa-body/-/koa-body-4.1.0.tgz#99295ee2e9543884e5730ae696780930b3821c44"
|
||||
integrity sha512-rWkMfMaCjFmIAMohtjlrg4BqDzcotK5BdZhiwJu1ONuR1ceoFUjnH3wp0hEV39HuBlc9tI3eUUFMK4Cp6ccFtA==
|
||||
dependencies:
|
||||
"@types/formidable" "^1.0.31"
|
||||
co-body "^5.1.1"
|
||||
formidable "^1.1.1"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user