funkwhale/api/funkwhale_api/common/storage.py

14 wiersze
361 B
Python
Czysty Zwykły widok Historia

import unicodedata
from django.core.files.storage import FileSystemStorage
class ASCIIFileSystemStorage(FileSystemStorage):
"""
Convert unicode characters in name to ASCII characters.
"""
2018-06-09 13:36:16 +00:00
def get_valid_name(self, name):
2018-06-09 13:36:16 +00:00
name = unicodedata.normalize("NFKD", name).encode("ascii", "ignore")
return super().get_valid_name(name)