kimetrica / django-binary-database-files

A storage system for Django that stores uploaded files in the database.
Other
11 stars 18 forks source link

URL_METHOD_2 still requires setting MEDIA_ROOT #23

Open remocrevo opened 4 years ago

remocrevo commented 4 years ago

With the following settings in my settings file, the url files/FILENAME.pdf successfully serves a file:

MEDIA_ROOT = os.path.join(BASE_DIR, 'media') DEFAULT_FILE_STORAGE = 'binary_database_files.storage.DatabaseStorage' DB_FILES_AUTO_EXPORT_DB_TO_FS = False DATABASE_FILES_URL_METHOD = 'URL_METHOD_2'

However, if I remove the MEDIA_ROOT setting, I get a FileNotFoundError with the following traceback:

/home/rjs7/git/hh_letters/hhenv/lib/python3.5/site-packages/binary_database_files/views.py in serve_mixed

I thought I could setup this package to avoid using the file system at all. But I see now that the files appear in my MEDIA_ROOT directory after I successfully download them, which I didn't expect. Maybe this just needs to be added to the documentation so people know they must set MEDIA_ROOT even if they don't want to serve files from the file system.

Thanks for your work on this package.

Remington

jsonn commented 4 years ago

There are two parts here. I think requiring MEDIA_ROOT to be set is reasonable, so I'm not touching that part. But always writing the file doesn't seem sensible and conflict with the name of the option. So #27 disables that part.