foldbank-mock/backend/foldbank/utils.py

20 lines
427 B
Python
Raw Normal View History

import pathlib
import datetime
def get_file_extension(file):
return pathlib.Path(file.name).suffix
def generate_filename_for_storage(file):
ext = get_file_extension(file)
filename = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
return f"{filename}{ext}"
def get_bank_logo_file_path(self, _):
filename = generate_filename_for_storage(self.logo)
return f"images/bank/{self.pk}/logo/{filename}"