mirror of https://github.com/zulip/zulip.git
thumbnaling: Support S3 upload backend in thumbor.
Credits for doing this goes to @sampritipanda.
This commit is contained in:
parent
98a4e87e1d
commit
529e4e76c8
|
@ -254,6 +254,7 @@ ENABLE_FILE_LINKS = False
|
||||||
LOCAL_UPLOADS_DIR = "/home/zulip/uploads"
|
LOCAL_UPLOADS_DIR = "/home/zulip/uploads"
|
||||||
#S3_AUTH_UPLOADS_BUCKET = ""
|
#S3_AUTH_UPLOADS_BUCKET = ""
|
||||||
#S3_AVATAR_BUCKET = ""
|
#S3_AVATAR_BUCKET = ""
|
||||||
|
#S3_REGION = ""
|
||||||
|
|
||||||
# Maximum allowed size of uploaded files, in megabytes. DO NOT SET
|
# Maximum allowed size of uploaded files, in megabytes. DO NOT SET
|
||||||
# ABOVE 80MB. The file upload implementation doesn't support chunked
|
# ABOVE 80MB. The file upload implementation doesn't support chunked
|
||||||
|
|
|
@ -166,6 +166,8 @@ DEFAULT_SETTINGS = {
|
||||||
# File uploads and avatars
|
# File uploads and avatars
|
||||||
'DEFAULT_AVATAR_URI': '/static/images/default-avatar.png',
|
'DEFAULT_AVATAR_URI': '/static/images/default-avatar.png',
|
||||||
'S3_AVATAR_BUCKET': '',
|
'S3_AVATAR_BUCKET': '',
|
||||||
|
'S3_AUTH_UPLOADS_BUCKET': '',
|
||||||
|
'S3_REGION': '',
|
||||||
'LOCAL_UPLOADS_DIR': None,
|
'LOCAL_UPLOADS_DIR': None,
|
||||||
'MAX_FILE_UPLOAD_SIZE': 25,
|
'MAX_FILE_UPLOAD_SIZE': 25,
|
||||||
|
|
||||||
|
|
|
@ -23,17 +23,16 @@ if PRODUCTION:
|
||||||
else:
|
else:
|
||||||
from zproject.dev_settings import LOCAL_UPLOADS_DIR
|
from zproject.dev_settings import LOCAL_UPLOADS_DIR
|
||||||
|
|
||||||
|
IS_LOCAL_STORAGE = bool(LOCAL_UPLOADS_DIR)
|
||||||
|
|
||||||
################################# File Loader ##################################
|
################################# File Loader ##################################
|
||||||
|
|
||||||
## The root path where the File Loader will try to find images
|
## The root path where the File Loader will try to find images
|
||||||
if os.path.isabs(LOCAL_UPLOADS_DIR):
|
if IS_LOCAL_STORAGE:
|
||||||
FILE_LOADER_ROOT_PATH = LOCAL_UPLOADS_DIR
|
if os.path.isabs(LOCAL_UPLOADS_DIR):
|
||||||
else:
|
FILE_LOADER_ROOT_PATH = LOCAL_UPLOADS_DIR
|
||||||
FILE_LOADER_ROOT_PATH = os.path.join(ZULIP_PATH, LOCAL_UPLOADS_DIR)
|
else:
|
||||||
|
FILE_LOADER_ROOT_PATH = os.path.join(ZULIP_PATH, LOCAL_UPLOADS_DIR)
|
||||||
################################################################################
|
|
||||||
|
|
||||||
IS_LOCAL_STORAGE = bool(LOCAL_UPLOADS_DIR)
|
|
||||||
|
|
||||||
################################### Logging ####################################
|
################################### Logging ####################################
|
||||||
|
|
||||||
|
@ -560,7 +559,8 @@ ALLOW_OLD_URLS = False
|
||||||
|
|
||||||
## Path where the Result storage will store generated images
|
## Path where the Result storage will store generated images
|
||||||
## Defaults to: '/tmp/thumbor/result_storage'
|
## Defaults to: '/tmp/thumbor/result_storage'
|
||||||
RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = os.path.join(FILE_LOADER_ROOT_PATH, 'thumbnails')
|
if IS_LOCAL_STORAGE:
|
||||||
|
RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = os.path.join(FILE_LOADER_ROOT_PATH, 'thumbnails')
|
||||||
|
|
||||||
## Indicates whether unsafe requests should also be stored in the Result Storage
|
## Indicates whether unsafe requests should also be stored in the Result Storage
|
||||||
## Defaults to: False
|
## Defaults to: False
|
||||||
|
@ -651,16 +651,23 @@ RESULT_STORAGE_STORES_UNSAFE = True
|
||||||
|
|
||||||
|
|
||||||
################################### AWS S3 settings ############################
|
################################### AWS S3 settings ############################
|
||||||
# TC_AWS_REGION= # AWS Region
|
|
||||||
|
|
||||||
# TC_AWS_STORAGE_BUCKET= # S3 bucket for Storage
|
if not IS_LOCAL_STORAGE:
|
||||||
# TC_AWS_STORAGE_ROOT_PATH= # S3 path prefix for Storage bucket
|
if PRODUCTION:
|
||||||
|
from zproject.prod_settings import S3_AUTH_UPLOADS_BUCKET, S3_REGION
|
||||||
|
else:
|
||||||
|
from zproject.dev_settings import S3_AUTH_UPLOADS_BUCKET, S3_REGION
|
||||||
|
|
||||||
# TC_AWS_LOADER_BUCKET= #S3 bucket for loader
|
TC_AWS_REGION = S3_REGION # AWS Region
|
||||||
# TC_AWS_LOADER_ROOT_PATH= # S3 path prefix for Loader bucket
|
|
||||||
|
|
||||||
# TC_AWS_RESULT_STORAGE_BUCKET= # S3 bucket for result Storage
|
TC_AWS_STORAGE_BUCKET = S3_AUTH_UPLOADS_BUCKET # S3 bucket for Storage
|
||||||
# TC_AWS_RESULT_STORAGE_ROOT_PATH= # S3 path prefix for Result storage bucket
|
TC_AWS_STORAGE_ROOT_PATH = 'thumbnails' # S3 path prefix for Storage bucket
|
||||||
|
|
||||||
|
TC_AWS_LOADER_BUCKET = S3_AUTH_UPLOADS_BUCKET #S3 bucket for loader
|
||||||
|
TC_AWS_LOADER_ROOT_PATH = '' # S3 path prefix for Loader bucket
|
||||||
|
|
||||||
|
TC_AWS_RESULT_STORAGE_BUCKET = S3_AUTH_UPLOADS_BUCKET # S3 bucket for result Storage
|
||||||
|
TC_AWS_RESULT_STORAGE_ROOT_PATH = 'thumbnails' # S3 path prefix for Result storage bucket
|
||||||
|
|
||||||
TC_AWS_MAX_RETRY=0 # Max retries for get image from S3 Bucket. Default is 0
|
TC_AWS_MAX_RETRY=0 # Max retries for get image from S3 Bucket. Default is 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue