mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
implement uploadStream wrapping for actionOptions
This commit is contained in:
parent
3bf25de33e
commit
091a3d3d85
7
packages/core/upload/server/bootstrap.js
vendored
7
packages/core/upload/server/bootstrap.js
vendored
@ -51,6 +51,10 @@ const createProvider = config => {
|
|||||||
|
|
||||||
return Object.assign(Object.create(baseProvider), {
|
return Object.assign(Object.create(baseProvider), {
|
||||||
...providerInstance,
|
...providerInstance,
|
||||||
|
original: providerInstance,
|
||||||
|
uploadStream(file, options = actionOptions.upload) {
|
||||||
|
return providerInstance.uploadStream(file, options);
|
||||||
|
},
|
||||||
upload(file, options = actionOptions.upload) {
|
upload(file, options = actionOptions.upload) {
|
||||||
return providerInstance.upload(file, options);
|
return providerInstance.upload(file, options);
|
||||||
},
|
},
|
||||||
@ -64,6 +68,9 @@ const baseProvider = {
|
|||||||
extend(obj) {
|
extend(obj) {
|
||||||
Object.assign(this, obj);
|
Object.assign(this, obj);
|
||||||
},
|
},
|
||||||
|
uploadStream() {
|
||||||
|
throw new Error('Provider uploadStream method is not implemented');
|
||||||
|
},
|
||||||
upload() {
|
upload() {
|
||||||
throw new Error('Provider upload method is not implemented');
|
throw new Error('Provider upload method is not implemented');
|
||||||
},
|
},
|
||||||
|
@ -5,7 +5,7 @@ const { streamToBuffer } = require('../utils/file');
|
|||||||
|
|
||||||
module.exports = ({ strapi }) => ({
|
module.exports = ({ strapi }) => ({
|
||||||
async upload(file) {
|
async upload(file) {
|
||||||
if (isFunction(strapi.plugin('upload').provider.uploadStream)) {
|
if (isFunction(strapi.plugin('upload').provider.original.uploadStream)) {
|
||||||
file.stream = file.getStream();
|
file.stream = file.getStream();
|
||||||
await strapi.plugin('upload').provider.uploadStream(file);
|
await strapi.plugin('upload').provider.uploadStream(file);
|
||||||
delete file.stream;
|
delete file.stream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user