Open
Description
Currently DatabaseStorage.path
is:
localpath = self._path(self.get_instance_name(name))
if not os.path.exists(localpath):
raise NotImplementedError
return localpath
I.e. if the file doesn't exist locally then it raises NotImplementedError
.
However, it is possible that if there are multiple webservers in front of a single database, then the file may be in the database but not in the local storage. The existing _open
includes:
# Automatically write the file to the filesystem
# if it's missing and exists in the database.
# This happens if we're using multiple web servers connected
# to a common database behind a load balancer.
# One user might upload a file from one web server, and then
# another might access if from another server.
utils.write_file(name, f.content)
We should apply the same approach to path
to automatically write the file to the local filesystem if it exists in the database but not locally.
Metadata
Metadata
Assignees
Labels
No labels