mirror of
https://github.com/strapi/strapi.git
synced 2025-11-14 09:07:59 +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);
|
const providerInstance = provider.init(providerOptions);
|
||||||
|
|
||||||
if (!providerInstance.delete) {
|
return Object.assign(Object.create(baseProvider), {
|
||||||
throw new Error(`The upload provider "${providerName}" doesn't implement the delete method.`);
|
...providerInstance,
|
||||||
}
|
upload(file, options = actionOptions.upload) {
|
||||||
|
return providerInstance.upload(file, options);
|
||||||
if (!providerInstance.upload && !providerInstance.uploadStream) {
|
},
|
||||||
throw new Error(
|
delete(file, options = actionOptions.delete) {
|
||||||
`The upload provider "${providerName}" doesn't implement the uploadStream nor the upload method.`
|
return providerInstance.delete(file, options);
|
||||||
);
|
},
|
||||||
}
|
|
||||||
|
|
||||||
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), wrappedProvider);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseProvider = {
|
const baseProvider = {
|
||||||
extend(obj) {
|
extend(obj) {
|
||||||
Object.assign(this, 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 () => {
|
const registerPermissionActions = async () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user