django-storage

Pointing to multiple S3 buckets in s3boto

ぃ、小莉子 提交于 2019-12-02 20:49:45
In settings.py I have: STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = 'xxxxxxxxxxxxx' AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxx' AWS_STORAGE_BUCKET_NAME = 'static.mysite.com' This is pointing to my S3 bucket static.mysite.com and works fine when I do manage.py collectstatic , it uploads all the static files to my bucket. However, I have another bucket which I use for different purposes and would like to use in certain areas of the website, for example if I have a model like this: class Image(models

Storing images and thumbnails on s3 in django

落花浮王杯 提交于 2019-12-02 14:55:59
I'm trying to get my images thumbnailed and stored on s3 using django-storages, boto, and sorl-thumbnail. I have it working, but it's very slow, even with small images. I don't mind it being slow when I save the form and upload the images to s3, but I'd like it to display the image quickly after that. The answer to this SO question explains that the thumbnail won't be created until first access, but that you can use get_thumbnail() to create it beforehand. Django + S3 (boto) + Sorl Thumbnail: Suggestions for optimisation I'm doing that, and now it seems that all entries into the thumbnail

Amazon S3 with Django can't load all the static files

为君一笑 提交于 2019-12-02 03:00:03
问题 I'm using Amazon S3 to be my static and media files storage. My Django project is running in Digital ocean ubuntu 16.04. After running python manage.py collectstatic I found the CSS and js did not work in my website. And then I found that the CSS and js hadn't been upload in the S3. I think this is the reason why the cs and js did not work because they are not in there. there is only 'static' folder in S3. in this static folder there are not my project static files but the a dmin xadmin and

Django - Error importing storages.backends

我的梦境 提交于 2019-12-01 03:32:19
I have created a custom storage backend, the file is called storages.py and is placed in an app called core : from django.conf import settings from storages.backends.s3boto import S3BotoStorage class S3StaticBucket(S3BotoStorage): def __init__(self, *args, **kwargs): kwargs['bucket_name'] = getattr(settings, 'static.mysite.com') super(S3BotoStorage, self).__init__(*args, **kwargs) In settings.py , I have the follwing: STATICFILES_STORAGE = 'core.storages.S3StaticBucket' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' When I try to do python manage.py collectstatic it shows the

Django - Error importing storages.backends

筅森魡賤 提交于 2019-12-01 00:49:01
问题 I have created a custom storage backend, the file is called storages.py and is placed in an app called core : from django.conf import settings from storages.backends.s3boto import S3BotoStorage class S3StaticBucket(S3BotoStorage): def __init__(self, *args, **kwargs): kwargs['bucket_name'] = getattr(settings, 'static.mysite.com') super(S3BotoStorage, self).__init__(*args, **kwargs) In settings.py , I have the follwing: STATICFILES_STORAGE = 'core.storages.S3StaticBucket' DEFAULT_FILE_STORAGE =

Why does S3 (using with boto and django-storages) give signed url even for public files?

时光毁灭记忆、已成空白 提交于 2019-11-30 08:37:21
This is strange. I have mix of public as well as private files. I want normal urls in public files, and signed urls in private files. I tried to change AWS_QUERYSTRING_AUTH to False as I see by default, it's True in django-storages. But, when I change it, my private files url is not signed (thus not accessible). May be I am missing something here. What can be solution? Thanks in advance. user2433326 AWS_QUERYSTRING_AUTH sets the default behavior, but you can override it when you create an instance of S3BotoStorage , by passing in an additional argument to the initializer: S3BotoStorage(bucket=

django-storages + sorl_thumbnail + S3 not working well together (URLs mismatch)

送分小仙女□ 提交于 2019-11-30 07:11:09
I am using django-storages and sorl_thumbnail together and I am using Amazon S3 for static and media files. I am using one bucket with 2 folders, 1 for static and 1 for media. Here is my config: MEDIA_ROOT = '/media/' MEDIA_URL = 'https://s3.amazonaws.com/my-bucket/media/' STATIC_ROOT = '/static/' STATIC_URL = 'https://s3.amazonaws.com/my-bucket/static/' AWS_STORAGE_BUCKET_NAME = 'my-bucket' DEFAULT_FILE_STORAGE = 'my_lib.s3utils.MediaRootS3BotoStorage' STATICFILES_STORAGE = 'my_lib.s3utils.StaticRootS3BotoStorage' MediaRootS3BotoStorage and StaticRootS3BotoStorage are defined like this:

collectstatic incorrectly creates multiple CSS files in S3

烈酒焚心 提交于 2019-11-29 13:03:00
I have uploading files to S3 working fine with my Wagtail/django application (both static and uploads). Now I'm trying to use ManifestStaticFilesStorage to enable cache busting. The urls are correctly being generated by the application and files are being copied with hashes to S3. But each time I run collectstatic some files get copied twice to S3 - each with a different hash. So far the issue is ocurring for all CSS files. file.a.css is loaded by the application and is the file referenced in staticfiles.json - however it is a 20.0B file in S3 (should be 6.3KB). file.b.css has the correct

Why does S3 (using with boto and django-storages) give signed url even for public files?

走远了吗. 提交于 2019-11-29 12:08:55
问题 This is strange. I have mix of public as well as private files. I want normal urls in public files, and signed urls in private files. I tried to change AWS_QUERYSTRING_AUTH to False as I see by default, it's True in django-storages. But, when I change it, my private files url is not signed (thus not accessible). May be I am missing something here. What can be solution? Thanks in advance. 回答1: AWS_QUERYSTRING_AUTH sets the default behavior, but you can override it when you create an instance

django-storages + sorl_thumbnail + S3 not working well together (URLs mismatch)

我只是一个虾纸丫 提交于 2019-11-29 09:47:45
问题 I am using django-storages and sorl_thumbnail together and I am using Amazon S3 for static and media files. I am using one bucket with 2 folders, 1 for static and 1 for media. Here is my config: MEDIA_ROOT = '/media/' MEDIA_URL = 'https://s3.amazonaws.com/my-bucket/media/' STATIC_ROOT = '/static/' STATIC_URL = 'https://s3.amazonaws.com/my-bucket/static/' AWS_STORAGE_BUCKET_NAME = 'my-bucket' DEFAULT_FILE_STORAGE = 'my_lib.s3utils.MediaRootS3BotoStorage' STATICFILES_STORAGE = 'my_lib.s3utils