mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +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), {
|
||||
...providerInstance,
|
||||
original: providerInstance,
|
||||
uploadStream(file, options = actionOptions.upload) {
|
||||
return providerInstance.uploadStream(file, options);
|
||||
},
|
||||
upload(file, options = actionOptions.upload) {
|
||||
return providerInstance.upload(file, options);
|
||||
},
|
||||
@ -64,6 +68,9 @@ const baseProvider = {
|
||||
extend(obj) {
|
||||
Object.assign(this, obj);
|
||||
},
|
||||
uploadStream() {
|
||||
throw new Error('Provider uploadStream method is not implemented');
|
||||
},
|
||||
upload() {
|
||||
throw new Error('Provider upload method is not implemented');
|
||||
},
|
||||
|
@ -5,7 +5,7 @@ const { streamToBuffer } = require('../utils/file');
|
||||
|
||||
module.exports = ({ strapi }) => ({
|
||||
async upload(file) {
|
||||
if (isFunction(strapi.plugin('upload').provider.uploadStream)) {
|
||||
if (isFunction(strapi.plugin('upload').provider.original.uploadStream)) {
|
||||
file.stream = file.getStream();
|
||||
await strapi.plugin('upload').provider.uploadStream(file);
|
||||
delete file.stream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user