Skip to content

Commit ea66622

Browse files
committed
update: custom storage
1 parent d3e677b commit ea66622

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pyconkr/settings-dev.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
from pyconkr.settings import *
4+
from pyconkr.storage import *
45

56
DEBUG = True
67

@@ -22,8 +23,12 @@
2223

2324
# django-storages: S3
2425
del MEDIA_ROOT
25-
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
26-
STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
26+
# DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
27+
# STATICFILES_STORAGE = "storages.backends.s3boto3.S3StaticStorage"
28+
29+
DEFAULT_FILE_STORAGE = MediaStorage
30+
STATICFILES_STORAGE = StaticStorage
31+
2732
AWS_S3_ACCESS_KEY_ID = os.getenv("AWS_S3_ACCESS_KEY_ID")
2833
AWS_S3_SECRET_ACCESS_KEY = os.getenv("AWS_S3_SECRET_ACCESS_KEY")
2934
AWS_DEFAULT_REGION = "ap-northeast-2"

pyconkr/storage.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.conf import settings
2+
from storages.backends.s3boto3 import S3Boto3Storage, S3StaticStorage
3+
4+
5+
class MediaStorage(S3Boto3Storage):
6+
def _get_security_token(self):
7+
return None
8+
9+
10+
class StaticStorage(S3StaticStorage):
11+
def _get_security_token(self):
12+
return None

0 commit comments

Comments
 (0)