s3 support for images
This commit is contained in:
@ -57,9 +57,8 @@ class Integration:
|
||||
recipe_stream.write(data)
|
||||
recipe_zip_obj.writestr(filename, recipe_stream.getvalue())
|
||||
recipe_stream.close()
|
||||
|
||||
try:
|
||||
recipe_zip_obj.write(r.image.path, 'image.png')
|
||||
recipe_zip_obj.writestr('image.png', r.image.file.read())
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
@ -147,10 +146,13 @@ class Integration:
|
||||
il.msg += f'{recipe.pk} - {recipe.name} \n'
|
||||
self.handle_duplicates(recipe, import_duplicates)
|
||||
except BadZipFile:
|
||||
il.msg += 'ERROR ' + _('Importer expected a .zip file. Did you choose the correct importer type for your data ?') + '\n'
|
||||
il.msg += 'ERROR ' + _(
|
||||
'Importer expected a .zip file. Did you choose the correct importer type for your data ?') + '\n'
|
||||
|
||||
if len(self.ignored_recipes) > 0:
|
||||
il.msg += '\n' + _('The following recipes were ignored because they already existed:') + ' ' + ', '.join(self.ignored_recipes) + '\n\n'
|
||||
il.msg += '\n' + _(
|
||||
'The following recipes were ignored because they already existed:') + ' ' + ', '.join(
|
||||
self.ignored_recipes) + '\n\n'
|
||||
|
||||
il.keyword = self.keyword
|
||||
il.msg += (_('Imported %s recipes.') % Recipe.objects.filter(keywords=self.keyword).count()) + '\n'
|
||||
|
@ -287,15 +287,28 @@ JS_REVERSE_SCRIPT_PREFIX = os.getenv('JS_REVERSE_SCRIPT_PREFIX', os.getenv('SCRI
|
||||
STATIC_URL = os.getenv('STATIC_URL', '/static/')
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
|
||||
|
||||
MEDIA_URL = os.getenv('MEDIA_URL', '/media/')
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
||||
if os.getenv('S3_ACCESS_KEY', ''):
|
||||
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||
|
||||
AWS_ACCESS_KEY_ID = os.getenv('S3_ACCESS_KEY', '')
|
||||
AWS_SECRET_ACCESS_KEY = os.getenv('S3_SECRET_ACCESS_KEY', '')
|
||||
AWS_STORAGE_BUCKET_NAME = os.getenv('S3_BUCKET_NAME', '')
|
||||
AWS_QUERYSTRING_AUTH = True
|
||||
|
||||
if os.getenv('S3_ENDPOINT_URL', ''):
|
||||
AWS_S3_ENDPOINT_URL = os.getenv('S3_ENDPOINT_URL', '')
|
||||
|
||||
MEDIA_URL = os.getenv('MEDIA_URL', '/media/')
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
||||
else:
|
||||
MEDIA_URL = os.getenv('MEDIA_URL', '/media/')
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles")
|
||||
|
||||
# Serve static files with gzip
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
TEST_RUNNER = "cookbook.helper.CustomTestRunner.CustomTestRunner"
|
||||
|
||||
|
||||
# settings for cross site origin (CORS)
|
||||
# all origins allowed to support bookmarklet
|
||||
# all of this may or may not work with nginx or other web servers
|
||||
|
@ -36,3 +36,5 @@ django-scopes==1.2.0
|
||||
pytest==6.2.4
|
||||
pytest-django==4.3.0
|
||||
django-cors-headers==3.7.0
|
||||
django-storages==1.11.1
|
||||
boto3==1.17.80
|
Reference in New Issue
Block a user