django-storages / django_storages /

import os

from django.conf import settings
from import FileSystemStorage

__all__ = ('OverwriteStorage',)

class OverwriteStorage(FileSystemStorage):

    def get_available_name(self, name):
        Returns a filename that's free on the target storage system, and
        available for new content to be written to.

        Comes from
        (even if it already exists in S3Storage for ages)

        See also Django #4339, which might add this functionality to core.
        if self.exists(name):
        return name