Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
The issue you’re experiencing with 403 errors on images uploaded via Summernote in a Django application and stored in DigitalOcean Spaces seems to be related to access permissions and potentially CORS settings.
What I could suggest is following this tutorial here:
https://www.digitalocean.com/community/tutorials/how-to-set-up-object-storage-with-django
If this still does not work, here are some general steps to troubleshoot and resolve this problem:
Public Access: By default, files uploaded to DigitalOcean Spaces are private. You need to set the uploaded images to be publicly accessible. You can set the default file permission to public for the Space where the images are stored.
Spaces Access Keys: If you don’t want your images to be public, another approach is to use DigitalOcean Spaces Access Keys. These keys allow your application to authenticate and access the private files programmatically.
Configure CORS: If your Django application is hosted on a different domain than your DigitalOcean Space, you may face CORS (Cross-Origin Resource Sharing) issues. Make sure the CORS settings for your Space are configured to allow requests from your application’s domain.
Check Headers: Ensure that the appropriate CORS headers are present in the responses for your image requests.
STATIC and MEDIA Settings: Ensure that your STATIC_URL and MEDIA_URL in your Django settings are correctly configured to serve files from DigitalOcean Spaces.
django-storages: If you’re using django-storages to integrate with DigitalOcean Spaces, make sure it’s properly configured. Check the settings related to the backend storage class and authentication credentials.
Access Images Directly: Try accessing the images directly via their URLs in the browser to see if they are accessible.
Log Files: Check your server logs for any additional information about the 403 errors.
Browser Console: Use the browser’s developer tools to inspect the network requests and responses for the images. Look for any clues in the response headers or request URLs.
Best,
Bobby
The 403 Forbidden error indicates a permission or access issue with the images stored in your DigitalOcean Spaces. Here’s how to troubleshoot and resolve the problem:
DigitalOcean Spaces is an S3-compatible object storage service. By default, objects in Spaces are private, meaning they are not accessible unless permissions are explicitly set or an authenticated request is made. When using Summernote to upload images, the uploaded images may inherit these default private settings.
Ensure that the uploaded files to Spaces are publicly accessible. You can achieve this by setting the ACL (Access Control List) to public-read during upload.
django-storages for DigitalOcean Spaces, add the following to your settings.py:AWS_DEFAULT_ACL = 'public-read'
When using Django Summernote to upload images, ensure the DEFAULT_FILE_STORAGE is correctly configured to use your DigitalOcean Spaces:
settings.py:from storages.backends.s3boto3 import S3Boto3Storage
class MediaStorage(S3Boto3Storage):
location = 'media' # Replace with your media directory name
file_overwrite = False
DEFAULT_FILE_STORAGE = 'your_project.settings.MediaStorage'
AWS_DEFAULT_ACL = 'public-read'
MEDIA_URL is properly configured:MEDIA_URL = f'{AWS_S3_ENDPOINT_URL}/media/'
settings.pySUMMERNOTE_CONFIG = {
'attachment_storage_class': 'your_project.settings.MediaStorage',
}
You mentioned previously experiencing CORS (Cross-Origin Resource Sharing) issues. Ensure your DigitalOcean Spaces bucket allows requests from your domain:
[
{
"AllowedHeaders": ["*"],
"AllowedMethods": ["GET", "HEAD"],
"AllowedOrigins": ["https://yourdomain.com"],
"ExposeHeaders": [],
"MaxAgeSeconds": 3000
}
]
Ensure the files in your Space have public permissions set. You can automate this for all future uploads using the public-read ACL in django-storages. However, for existing files:
s3cmd tool to make existing files public:s3cmd setacl s3://your-space-name/media/ --acl-public --recursive
If the problem persists:
Inspect the URL of the failing images:
https://your-space-name.nyc3.digitaloceanspaces.com/media/your-image.jpg.Check Logs for Errors:
Test Access to Files:
STATICFILES_STORAGE and DEFAULT_FILE_STORAGE settings to manage static and media files in DigitalOcean Spaces automatically.public-read) to avoid manual intervention.