Closed MayerBjoern closed 3 years ago
Hey, sorry for the delayed reply and thank you for the pull request!
I'm not sure I 100% understand the use case for this. At this time, files cannot be deleted or modified once uploaded, but new files can be uploaded and existing files can be hidden from general users, e.g. if a file was uploaded unintentionally. This follows the principle that metadata in SampleDB should be a permanent archive, with the option for providing updated information, but without modifying or removing existing information.
Overwriting a file would try to find another existing file, replace its data attribute and then write the corresponding binary data to the database or file to the file system, thereby removing the existing information. What is the motivation or use case for not leaving the existing information accessible?
Aside from this larger question, there's also the issue of moving between storage types, e.g. switching from local file storage to database file storage will leave the actual file in the file storage path unchanged. And if there are multiple existing files with the same original_file_name, the first returned by the database will be replaced. That seems somewhat arbitrary.
New Parameter for the file upload API. overwrite is optional and default is False.
If true and a file with the given name already exists, the file will now be replaced. Otherwise a new file will be created (same behaviour then before).