From 542433598aad0efffee7619e1f113425147bcec0 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 1 Mar 2021 11:13:07 +0530 Subject: Add AWS support for file upload --- yaksh/storage_backends.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 yaksh/storage_backends.py (limited to 'yaksh/storage_backends.py') diff --git a/yaksh/storage_backends.py b/yaksh/storage_backends.py new file mode 100644 index 0000000..4d08c8c --- /dev/null +++ b/yaksh/storage_backends.py @@ -0,0 +1,18 @@ +from django.conf import settings +from storages.backends.s3boto3 import S3Boto3Storage + + +class StaticStorage(S3Boto3Storage): + location = settings.AWS_STATIC_LOCATION if settings.USE_AWS else settings.STATIC_URL + + +class PublicMediaStorage(S3Boto3Storage): + location = settings.AWS_PUBLIC_MEDIA_LOCATION if settings.USE_AWS else settings.MEDIA_URL + file_overwrite = False + + +class PrivateMediaStorage(S3Boto3Storage): + location = settings.AWS_PRIVATE_MEDIA_LOCATION if settings.USE_AWS else settings.MEDIA_URL + default_acl = 'private' + file_overwrite = False + custom_domain = False \ No newline at end of file -- cgit From cc101bd195cc456f7bace4e9b646e2190975dde3 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 23 Mar 2021 11:53:39 +0530 Subject: Modify file upload with js client dropzone --- yaksh/storage_backends.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'yaksh/storage_backends.py') diff --git a/yaksh/storage_backends.py b/yaksh/storage_backends.py index 4d08c8c..206e456 100644 --- a/yaksh/storage_backends.py +++ b/yaksh/storage_backends.py @@ -3,16 +3,16 @@ from storages.backends.s3boto3 import S3Boto3Storage class StaticStorage(S3Boto3Storage): - location = settings.AWS_STATIC_LOCATION if settings.USE_AWS else settings.STATIC_URL + if settings.USE_AWS: + location = settings.AWS_STATIC_LOCATION + else: + pass class PublicMediaStorage(S3Boto3Storage): - location = settings.AWS_PUBLIC_MEDIA_LOCATION if settings.USE_AWS else settings.MEDIA_URL - file_overwrite = False - - -class PrivateMediaStorage(S3Boto3Storage): - location = settings.AWS_PRIVATE_MEDIA_LOCATION if settings.USE_AWS else settings.MEDIA_URL - default_acl = 'private' - file_overwrite = False - custom_domain = False \ No newline at end of file + if settings.USE_AWS: + location = settings.AWS_PUBLIC_MEDIA_LOCATION + file_overwrite = True + default_acl = 'public-read' + else: + pass -- cgit