Setup S3 bucket for project

Hi @luke.smith,

AFAIK, str casts the type to String immediately, whereas get tries to detect the type, either way it has no practical difference in this case, so long as the result doesn’t raise an error when the value isn’t present, because it will only be present in production environment.

Here’s the link to the crowdbotics-django-scaffold, I’m fairly certain your project is using the latest version. We don’t include S3Boto by default since not all projects will be using it but might benefit from a smaller footprint in deployment.

Are you referring to static files, such as image assets, etc.? Or are you referring to uploaded files?

@dmitrii.k,

Nevermind, all is now working! It seems the issue was simply adding the dependencies.
Thanks again for all of your help!

1 Like

You are always welcome, @luke.smith!

Post here if you have any more questions or need help with anything.

Happy coding!

Priority: Normal
Project: Spiralmath
App Link: https://app.crowdbotics.com/dashboard/app/17663.
Can someone help me add S3 to the app?
CC @zix

1 Like

Hi @znatali, welcome to the community!

I’ve enabled S3 for your app. Refer to the following variables to configure your S3 storage:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
AWS_STORAGE_REGION

Hi @dmitrii.k Thank you. I’ve put those parameters into the settings this way:
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’)
AWS_STORAGE_REGION = os.getenv(‘AWS_STORAGE_REGION’)
AWS_LOCATION = ‘static’
and I have installed the django-boto, django-storages, boto3, botocore packages. But I still don’t have files in the static folder. Could you please provide the access to the AWS dashboard that I can check is my images there and how I can retrieve them?

Hi @znatali, thanks for posting your question.

I’m afraid I can’t provide you with access to AWS dashboard.

Please follow this guide - https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html to set up your S3 storage. Please be aware that we do not support S3 for static files storage, use the S3 backend only for the DEFAULT_FILE_STORAGE.

Make sure you also specify the AWS_DEFAULT_ACL as public-read (or pass ACL configuration to Boto3 specifically), or your files will not be accessible to your users (unless you generate pre-signed URLs).

Hi @dmitrii.k I’ve updated settings, it looks this now:
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’)
AWS_STORAGE_REGION = os.getenv(‘AWS_STORAGE_REGION’)
AWS_DEFAULT_ACL = ‘public-read’
DEFAULT_FILE_STORAGE = ‘storages.backends.s3boto3.S3Boto3Storage’
But I’m still getting error from saving pictures. Please have a look on those screenshots. Could you please advise me what could be wrong?

@znatali You nave to set signature version as AWS_S3_SIGNATURE_VERSION = 's3v4', then it will work fine.

1 Like

@saurav Thank you a lot! It works fine now.