Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/strapi-plugin-upload/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"provider": "local",
"providerOptions": {
"sizeLimit": 1000000
}
},
"actionOptions": {}
}
10 changes: 7 additions & 3 deletions packages/strapi-plugin-upload/config/functions/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ const wrapFunctionForErrors = fn => async (...args) => {
}
};

const createProvider = ({ provider, providerOptions }) => {
const createProvider = ({ provider, providerOptions, actionOptions = {} }) => {
try {
const providerInstance = require(`strapi-provider-upload-${provider}`).init(providerOptions);

return Object.assign(Object.create(baseProvider), {
...providerInstance,
upload: wrapFunctionForErrors(providerInstance.upload.bind(providerInstance)),
delete: wrapFunctionForErrors(providerInstance.delete.bind(providerInstance)),
upload: wrapFunctionForErrors((file, options = actionOptions.upload) => {
return providerInstance.upload(file, options);
}),
delete: wrapFunctionForErrors((file, options = actionOptions.delete) => {
return providerInstance.delete(file, options);
}),
});
} catch (err) {
strapi.log.error(err);
Expand Down
6 changes: 6 additions & 0 deletions packages/strapi-provider-upload-cloudinary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Your configuration is passed down to the cloudinary configuration. (e.g: `cloudinary.config(config)`). You can see the complete list of options [here](https://cloudinary.com/documentation/cloudinary_sdks#configuration_parameters)

`actionOptions` are passed directly to the upload and delete functions respectively allowing for custom options such as folder, type, etc. You can see the complete list of upload options [here](https://cloudinary.com/documentation/image_upload_api_reference#upload_optional_parameters) and delete options [here](https://cloudinary.com/documentation/image_upload_api_reference#destroy_optional_parameters)

See the [using a provider](https://strapi.io/documentation/developer-docs/latest/plugins/upload.html#using-a-provider) documentation for information on installing and using a provider. And see the [environment variables](https://strapi.io/documentation/developer-docs/latest/concepts/configurations.html#environment-variables) for setting and using environment variables in your configs.

**Example**
Expand All @@ -20,6 +22,10 @@ module.exports = ({ env }) => ({
api_key: env('CLOUDINARY_KEY'),
api_secret: env('CLOUDINARY_SECRET'),
},
actionOptions: {
upload: {},
delete: {}
}
},
// ...
});
Expand Down