Need custom storage to have two different paths

This commit is contained in:
2023-03-24 15:17:55 -04:00
parent 1e17a679d3
commit 2c946c1071
2 changed files with 16 additions and 2 deletions

View File

@ -257,8 +257,8 @@ if os.getenv("VROBBLER_USE_S3", "False").lower() in TRUTHY:
location = "/".join([AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME])
print(f"Storing media on S3 at {location}")
DEFAULT_FILE_storage = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
DEFAULT_FILE_storage = "vrobbler.storages.MediaStorage"
STATICFILES_STORAGE = "vrobbler.storages.StaticStorage"
STATIC_URL = location + "/static/"
MEDIA_URL = location + "/media/"

14
vrobbler/storages.py Normal file
View File

@ -0,0 +1,14 @@
import os
from storages.backends.s3boto3 import S3Boto3Storage
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME", "")
class MediaStorage(S3Boto3Storage):
bucket_name = AWS_STORAGE_BUCKET_NAME
location = "media"
class StaticStorage(S3Boto3Storage):
bucket_name = AWS_STORAGE_BUCKET_NAME
location = "static"