-
-
Save brunomichetti/72f8992ec2013e221b18641eefb566f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# your settings file | |
import os | |
from django.utils import timezone | |
from django.utils.text import slugify | |
… | |
EXAMPLE_DEST_KEY = 'images/example-images/' | |
TIMESTAMP_FORMAT = '%m-%d-%Y_%H-%M-%S-%f' | |
def normalize_filename(filename): | |
name, extension = os.path.splitext(filename) | |
time_stamp = timezone.now().strftime(TIMESTAMP_FORMAT) | |
return f'{time_stamp}--{slugify(name)}{extension}' | |
S3DIRECT_DESTINATIONS = { | |
'example_destination': { | |
'key': lambda filename: f'{EXAMPLE_DEST_KEY}/{normalize_filename(filename)}', | |
'region': AWS_S3_REGION_NAME, | |
'acl': 'private', | |
'allow_existence_optimization': False, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment