recordtransfer.storage - Custom storage definitions

class recordtransfer.storage.OverwriteStorage(*args, **kwargs)

Bases: FileSystemStorage

Overwrites files in storage if they have the same name.

Django’s default method of storing files named the same thing is to append a unique suffix to the file name and saving the duplicate file there. This class overrides that behviour and overwrites any file being saved with a path that already exists.

get_available_name(name: str, max_length: int | None = None) str

Return the provided file name as the available name, allowing overwriting of existing files.