mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +00:00
Merge pull request #12997 from strapi/revert-12838-fix/upload-actionOptions
Revert "Fix actionOptions not taking into account by the upload provider"
This commit is contained in:
commit
8b65a9501f
36
packages/core/upload/server/bootstrap.js
vendored
36
packages/core/upload/server/bootstrap.js
vendored
@ -49,35 +49,27 @@ const createProvider = config => {
|
||||
|
||||
const providerInstance = provider.init(providerOptions);
|
||||
|
||||
if (!providerInstance.delete) {
|
||||
throw new Error(`The upload provider "${providerName}" doesn't implement the delete method.`);
|
||||
}
|
||||
|
||||
if (!providerInstance.upload && !providerInstance.uploadStream) {
|
||||
throw new Error(
|
||||
`The upload provider "${providerName}" doesn't implement the uploadStream nor the upload method.`
|
||||
);
|
||||
}
|
||||
|
||||
if (!providerInstance.uploadStream) {
|
||||
process.emitWarning(
|
||||
`The upload provider "${providerName}" doesn't implement the uploadStream function. Strapi will fallback on the upload method. Some performance issues may occur.`
|
||||
);
|
||||
}
|
||||
|
||||
const wrappedProvider = _.mapValues(providerInstance, (method, methodName) => {
|
||||
return async function(file, options = actionOptions[methodName]) {
|
||||
return providerInstance[methodName](file, options);
|
||||
};
|
||||
return Object.assign(Object.create(baseProvider), {
|
||||
...providerInstance,
|
||||
upload(file, options = actionOptions.upload) {
|
||||
return providerInstance.upload(file, options);
|
||||
},
|
||||
delete(file, options = actionOptions.delete) {
|
||||
return providerInstance.delete(file, options);
|
||||
},
|
||||
});
|
||||
|
||||
return Object.assign(Object.create(baseProvider), wrappedProvider);
|
||||
};
|
||||
|
||||
const baseProvider = {
|
||||
extend(obj) {
|
||||
Object.assign(this, obj);
|
||||
},
|
||||
upload() {
|
||||
throw new Error('Provider upload method is not implemented');
|
||||
},
|
||||
delete() {
|
||||
throw new Error('Provider delete method is not implemented');
|
||||
},
|
||||
};
|
||||
|
||||
const registerPermissionActions = async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user