#26562: Introduce Storage and FileSystemStorage alternate save behaviour
-------------------------------------+-------------------------------------
     Reporter:  freshquiz            |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  File                 |                  Version:  master
  uploads/storage                    |
     Severity:  Normal               |               Resolution:
     Keywords:  file FileField       |             Triage Stage:  Accepted
  storage overwrite filepath         |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by freshquiz):

 Replying to [comment:10 timgraham]:
 > The concern about clobbering files is this: if user A uploads a file
 named "foo.txt" for model instance A, then user B could upload a file of
 the same name for model instance B and it would overwrite the first
 file.''

 I don't understand why you see that as too dangerous/hard for the client
 to be able to handle.
 Again, I ask why Django provides `Model.delete()` and `raw()` if you think
 the clients are so careless?

 > Again, I'd ask if you could please elaborate on your use case so we can
 better understand exactly what problem needs to be solved.

 I'm sorry, I missed the part about you asking for my use case.

 Yes, I am using a callable `upload_to`, which does allow me to partially
 control the storage path/key, but the current behaviour of mangling the
 final path/key (with random characters) prevents me from having total
 control.

 I use a combination of model name, field name and UUID to generate unique
 storage paths/keys, via `upload_to`.
 My use case goal is to ensure the following tuple does not result in
 clobbering/overwriting:
 `(model_name, field_name, UUID)`, where the UUID part is just a substitute
 for a primary key.

 I don't take into account file name for uniqueness, but that's just
 because of my use case.
 E.g. If there is a model instance with model '''ModelABC''' that has
 `FileField` named '''xyz''' and gets a UUID of '''123''', regardless of
 how many files are uploaded and what their end-user specified names are,
 there will only ever be one file present in the storage system.

 Please let me know if you need more info about my use case.

 Maybe this use case is too esoteric to warrant a "native" new feature.
 I just thought it would benefit others, given how many discussions and
 clunky workarounds I came across while trying to cook up a neat
 workaround/solution for myself.

--
Ticket URL: <https://code.djangoproject.com/ticket/26562#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.42d1e25f56ddd0e336df50e042ab7bfd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to