django-s3-storage icon indicating copy to clipboard operation
django-s3-storage copied to clipboard

How to access bucket subfolders?

Open betancourtl opened this issue 4 years ago • 2 comments

How can I set the location of the static files? I've done this before when using django-storages but I'm not sure how it works with this package.

This is how I have been able to set this up using django-storages

class MediaStorage(S3Boto3Storage):
    bucket_name = 'my-app-bucket'
    location = 'media'

class StaticStorage(S3Boto3Storage):
    bucket_name = 'my-app-bucket'
    location = 'static'

betancourtl avatar May 22 '20 15:05 betancourtl

The AWS_S3_KEY_PREFIX setting (suffixed with _STATIC if necessary), is what you want.

On Fri, 22 May 2020 at 16:01, Luis [email protected] wrote:

How can I set the location of the static files? I've done this before when using django-storages but I'm not sure how it works with this package.

class MediaStorage(S3Boto3Storage): bucket_name = 'my-app-bucket' location = 'media' class StaticStorage(S3Boto3Storage): bucket_name = 'my-app-bucket' location = 'static'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/django-s3-storage/issues/109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEKCBVK464A27I4VLVKKLRS2HVHANCNFSM4NH3M5RA .

etianen avatar May 22 '20 17:05 etianen

I had exactly the same question. The following does the trick.

AWS_S3_KEY_PREFIX = 'media' AWS_S3_KEY_PREFIX_STATIC = 'static'

@etianen: Thanks for the work on django-s3-storage. Works really well 👍

4ka0 avatar Feb 22 '21 06:02 4ka0