Technologies:
Tolerim
a month ago
How do I transfer images from strapi to Digital Ocean Spaces?
DOSPACEACCESS_KEY=access-key-from-spaces
DOSPACESECRET_KEY=access-secret-from-spaces
DOSPACEENDPOINT=ams3.digitaloceanspaces.com
DOSPACEBUCKET=my-bucket-name-here
DOSPACEDIRECTORY=/
DOSPACECDN=https://my-bucket-name-here.ams3.cdn.digitaloceanspaces.com
module.exports = ({env}) => ({
// ...
upload: {
config: {
provider: "strapi-provider-upload-do",
providerOptions: {
key: env('DOSPACEACCESS_KEY'),
secret: env('DOSPACESECRET_KEY'),
endpoint: env('DOSPACEENDPOINT'),
space: env('DOSPACEBUCKET'),
directory: env('DOSPACEDIRECTORY'),
cdn: env('DOSPACECDN'),
}
},
},
// ...
})
https://https//5ddca55609adfdd79f85c9c5c01c6c63.svg
, instead of the original URL of the image inside Spaces. Is there a potential flaw in my configuration, and what measures can I adopt to rectify this?Answers(2)
Vogi
a month ago
Verified Answer
I'm sorry to hear that you are facing issues while uploading images to Digital Ocean Spaces from the Strapi admin panel. I found a similar issue on StackOverflow where the user was facing the same issue as you. The user had configured the Strapi admin panel correctly but the images were not being uploaded to Digital Ocean Spaces. The URL for uploaded images was also incorrect, displayed as https://https//5ddca55609adfdd79f85c9c5c01c6c63.svg instead of the original URL of the image inside Spaces.
One solution that worked for some users was to use the official @strapi/provider-upload-aws-s3 plugin instead of the strapi-provider-upload-do plugin. This plugin is used to upload media to AWS S3 which is used by Digital Ocean Spaces to store media. You can configure your plugins.js file like this:
module.exports = ({env}) => ({
// ...
upload: {
config: {
provider: "aws-s3",
providerOptions: {
accessKeyId: env('AWS_ACCESS_KEY_ID'),
secretAccessKey: env('AWS_ACCESS_SECRET'),
region: env('AWS_REGION'),
params: {
Bucket: env('AWS_BUCKET_NAME'),
},
},
},
},
// ...
})
Another solution that worked for some users was to use one of these plugins to save uploaded images via Spaces:
- https://github.com/lbadger/strapi-upload-digitalocean
- https://github.com/AdamZikmund/strapi-provider-upload-digitalocean
I hope this helps! Let me know if you have any other questions.
Sources
Can't upload images from strapi to Digital Ocean SpacesUpload media to digitalocean spaces using strapi v4Strapi Docker on DigitalOcean - Content types and admin user is ...Upload media to digitalocean spaces using strapi v4Tolerim
a month ago
Unfortunately, as an AI language model, I am not able to access your Digital Ocean Spaces account or debug your code and configuration directly. However, there are a few things you can try to troubleshoot the issue:
1. Make sure that your Digital Ocean Spaces Access Key and Secret Key are correct and have the required permissions to upload files to the specified bucket.
2. Check if there are any errors or logs in the Strapi console or server logs that could indicate the cause of the problem.
3. Check that the provider package strapi-provider-upload-do is installed and properly configured in your Strapi project.
4. Double-check the DO_SPACE_DIRECTORY configuration option. This should point to the directory in your bucket where you want to upload the files.
5. Verify that the CDN URL DO_SPACE_CDN is correct. If this is incorrect, it could lead to broken image URLs like the one you described.
If none of these solutions work, you could also try reaching out to the Strapi community or Digital Ocean support for further assistance.