1

I have an S3 storage which is not hosted by AWS. I tried my AWS account as a file-storage, which worked fine, however, when I switch the credentials to the non-AWS provider I get:

botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden

in the django logs, and

ClientError at /admin/api/metabolomicsmzxml/add/ An error occurred (403) when calling the HeadObject operation: Forbidden

displayed in the browser.

I use django-storages with the following configuration:q :

AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.getenv('AWS_STORAGE_BUCKET_NAME')
AWSS_S3_SIGNATURE_VERSION = 's3v4'
AWS_S3_REGION_NAME = 'ca-central-1'
AWS_S3_FILE_OVERWRITE = False
AWS_DEFAULT_ACL = None
AWS_S3_VERIFY = True
AWS_ENDPOINT_URL = 'example.com:443'

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' 

Is it possible to use django-storages and boto3 with a non-AWS provider? Are there other packages that I should try?


I tried

AWS_S3_ENDPOINT_URL = 'example.com:443'

and

AWS_S3_ENDPOINT_URL = 'example.com'

then I get

ValueError: Invalid endpoint: ...

1 Answer 1

0

It finally worked.

I had to change the format of the S3 endpoint to:

'https://example.com'

And it works! I can now use a non-AWS S3 storage with django.

Sign up to request clarification or add additional context in comments.

2 Comments

Just curious, are you using Digital Ocean Spaces?
No, its a educational provider.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.