Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit a565434

Browse files
committed
fixed private media storage in loocal development
1 parent cdff9d9 commit a565434

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

backend/apps/banking/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
from backend.storage_backends import PrivateMediaStorage
2+
13
from django.db import models
24

35
# Create your models here.
46

57

68
class StatementFile(models.Model):
7-
statement_file = models.FileField()
9+
statement_file = models.FileField(
10+
storage=PrivateMediaStorage, upload_to="banking"
11+
)
812
month = models.DateField(null=False, blank=False)
913

1014
def __str__(self):

backend/backend/storage_backends.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
from django.conf import settings
2+
from django.core.files.storage import FileSystemStorage
23
from storages.backends.s3boto3 import S3Boto3Storage
34

45

56
class StaticStorage(S3Boto3Storage):
67
location = settings.AWS_STATIC_LOCATION
78

89

9-
class PrivateMediaStorage(S3Boto3Storage):
10-
location = settings.AWS_PRIVATE_MEDIA_LOCATION
11-
default_acl = "private"
12-
file_overwrite = False
13-
custom_domain = False
10+
if settings.DEBUG:
11+
12+
class PrivateMediaStorage(FileSystemStorage):
13+
location = settings.AWS_PRIVATE_MEDIA_LOCATION
14+
15+
16+
else:
17+
18+
class PrivateMediaStorage(S3Boto3Storage):
19+
location = settings.AWS_PRIVATE_MEDIA_LOCATION
20+
default_acl = 'private'
21+
file_overwrite = False
22+
custom_domain = False

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ services:
9292
- main
9393
environment:
9494
- CI_PIPELINE_TRIGGERED=True
95-
- SECRET_KEY=${SECRET_KEY}
95+
- SECRET_KEY=secret-key-for-development
9696
- DEBUG=True
9797
- DJANGO_EMAIL_HOST=${DJANGO_EMAIL_HOST}
9898
- DJANGO_EMAIL_PORT=${DJANGO_EMAIL_PORT}

0 commit comments

Comments
 (0)