yarn add @lyl-radio/strapi-provider-upload-do
npm install @lyl-radio/strapi-provider-upload-do --save
provider
defines the name of the providerproviderOptions
is passed down during the construction of the provider.actionOptions
is passed directly to the parameters to each method respectively. DigitalOcean Spaces is compatible with the Amazon Simple Storage Service (S3) API. You can find the complete list of upload/ uploadStream options and delete options
See the documentation about using a provider for information on installing and using a provider. To understand how environment variables are used in Strapi, please refer to the documentation about environment variables.
./config/plugins.js
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: '@lyl-radio/strapi-provider-upload-do',
providerOptions: {
key: env('DO_SPACE_ACCESS_KEY'),
secret: env('DO_SPACE_SECRET_KEY'),
endpoint: env('DO_SPACE_ENDPOINT'),
space: env('DO_SPACE_BUCKET'),
directory: env('DO_SPACE_DIRECTORY'),
cdn: env('DO_SPACE_CDN'),
},
actionOptions: {
upload: {},
uploadStream: {},
delete: {},
},
},
},
// ...
});
Due to the default settings in the Strapi Security Middleware you will need to modify the contentSecurityPolicy
settings to properly see thumbnail previews in the Media Library. You should replace strapi::security
string with the object bellow instead as explained in the middleware configuration documentation.
./config/middlewares.js
module.exports = [
// ...
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': [
"'self'",
'data:',
'blob:',
'yourBucketName.yourRegion.digitaloceanspaces.com',
'yourBucketName.yourRegion.cdn.digitaloceanspaces.com',
],
'media-src': [
"'self'",
'data:',
'blob:',
'yourBucketName.yourRegion.digitaloceanspaces.com',
'yourBucketName.yourRegion.cdn.digitaloceanspaces.com',
],
upgradeInsecureRequests: null,
},
},
},
},
// ...
];
You can also add your custom CDN subdomain to img-src and media-src directives.