Skip to content

Commit

Permalink
Revert "moved media and static storage from dropbox to backblaze #58"
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdeathway authored Dec 3, 2023
1 parent dddf6a6 commit 47ff273
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 40 deletions.
37 changes: 11 additions & 26 deletions archiver/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os
from pathlib import Path
from .secgen import generate_secret_key
from archiver import is_available,storage_backend
from archiver import is_available
from dotenv import load_dotenv
load_dotenv()

Expand Down Expand Up @@ -157,9 +157,10 @@


STATIC_ROOT = os.path.join(BASE_DIR,'staticfiles')
STATIC_URL = '/static/'

MEDIA_ROOT=os.path.join(BASE_DIR,'media')

MEDIA_URL='/media/'

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
Expand Down Expand Up @@ -203,32 +204,18 @@
},
'attachment_filesize_limit':FILE_SIZE_LIMIT,
'attachment_require_authentication': True,

}


DEFAULT_FILE_STORAGE = 'archiver.storage_backend.MediaStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
#dropbox settings
DEFAULT_FILE_STORAGE = 'storages.backends.dropbox.DropBoxStorage'
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" #"storages.backends.dropbox.DropboxStorage"
#DROPBOX_OAUTH2_TOKEN = os.environ.get('DROPBOX_OAUTH2_TOKEN')
DROPBOX_ROOT_PATH = '/k9archiver/'
DROPBOX_APP_KEY = os.environ.get('DROPBOX_APP_KEY')
DROPBOX_APP_SECRET = os.environ.get('DROPBOX_APP_SECRET')
DROPBOX_OAUTH2_REFRESH_TOKEN=os.environ.get('DROPBOX_OAUTH2_REFRESH_TOKEN')

#[V-dev4.1.0] AWS/Backblaze settings for Media Storage
AWS_ACCESS_KEY_ID =os.environ.get('AWS_ACCESS_KEY_ID') #b2 application key id if using backblaze'
AWS_SECRET_ACCESS_KEY =os.environ.get('AWS_SECRET_ACCESS_KEY') #your b2 application key
AWS_STORAGE_BUCKET_NAME =os.environ.get('AWS_STORAGE_BUCKET_NAME') #'<a public bucket>'
AWS_S3_REGION_NAME =os.environ.get('AWS_S3_REGION_NAME') #'<your b2 region - e.g. us-west-001>'

AWS_S3_ENDPOINT = f's3.{AWS_S3_REGION_NAME}.backblazeb2.com'
AWS_S3_ENDPOINT_URL = f'https://{AWS_S3_ENDPOINT}'

AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}

STATIC_URL = f"https://{AWS_STORAGE_BUCKET_NAME}.{AWS_S3_ENDPOINT}/"
#django debug toolbar and other settings for development
if DEBUG:
#if DEBUG is False then we are in production and we want to use postgres.
Expand All @@ -254,11 +241,9 @@
}

#django storages settings for development
#if USE_LOCAL_STORAGE is True then we will use local storage in development
USE_LOCAL_STORAGE=os.environ.get('USE_LOCAL_STORAGE', False) == 'True'
if USE_LOCAL_STORAGE:
STATIC_URL='/static/'
MEDIA_URL='/media/'
STATICFILES_STORAGE="whitenoise.storage.CompressedManifestStaticFilesStorage"
#if USE_DROPBOX_IN_DEVELOPMENT is True then we will use dropbox in development
#it is to test dropbox functionality in development
USE_DROPBOX_IN_DEVELOPMENT=os.environ.get('USE_DROPBOX_IN_DEVELOPMENT', False) == 'True'
if not(USE_DROPBOX_IN_DEVELOPMENT):
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'

5 changes: 0 additions & 5 deletions archiver/storage_backend.py

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ urllib3==1.26.18
webencodings==0.5.1
whitenoise==6.6.0
wrapt==1.13.3
boto3==1.33.6
10 changes: 2 additions & 8 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,5 @@ DROPBOX_APP_KEY=""
DROPBOX_APP_SECRET=""
DROPBOX_OAUTH2_REFRESH_TOKEN=""

#for using local storage in development
USE_LOCAL_STORAGE=True

#AWS/BackBlaze configuration
AWS_ACCESS_KEY_ID =''
AWS_SECRET_ACCESS_KEY =''
AWS_STORAGE_BUCKET_NAME =''
AWS_S3_REGION_NAME=''
#for testing dropbox related functionality in development
USE_DROPBOX_IN_DEVELOPMENT=False

0 comments on commit 47ff273

Please sign in to comment.