ic-labs / django-icekit

GLAMkit is a next-generation Python CMS by the Interaction Consortium, designed especially for the cultural sector.
http://glamkit.com
MIT License
47 stars 11 forks source link

Use deterministic unique file names for file and image libraries #224

Open mrmachine opened 7 years ago

mrmachine commented 7 years ago

Our default storage class for file and image libraries should automatically determine the file name name by hashing the file content. This will:

1) De-duplicate uploads 2) Allow us to serve all files (not only static media) with far-future expiry (100 years)

We should store the original file name in a field on the model, so we can set it on response headers so that direct downloads will be saved locally with the original filename. This means we can also have multiple distinct files for download with the same file name metadata.

The admin change list should show and search the original filename.

This behaviour is already implemented in an ixc-whitenoise mixin, and commented out in ICEkit's default storage class:

We just need to:

jmurty commented 7 years ago

This approach would also help #161 : Two file uploads with the same filename will overwrite each other