Disable overwrite of existing file?

50 views
Skip to first unread message

crobison

unread,
Aug 11, 2012, 3:59:49 PM8/11/12
to djangofi...@googlegroups.com
Is there a setting I am missing or way to disallow overwrites of a file of the same name?  I've tried doing this with the filebrowser_pre_upload signal but I don't believe it actually changes the file being uploaded nor does it return anything to _upload_file.

Any advice on how to do this without modifying the filebrowser source?

What is filebrowser_pre_upload meant for?  I can't think of any good use to it if it doesn't actually return anything to _upload_file.  I could just be mistaken though.

Thanks!

patrick kranzlmueller

unread,
Aug 13, 2012, 11:39:01 AM8/13/12
to djangofi...@googlegroups.com
acc. to the documentation (django) about FileSystemStorage, an underscore is to be added if a file already exists ... see https://github.com/django/django/blob/master/django/core/files/storage.py#L62

so, this is not related to the filebrowser source.

filebrowser_pre_upload doesn´t return the uploaded_file (because it´s not uploaded yet!!!). the signal could (for example) be used in order to add data to the upload.

regards,
patrick


2012/8/11 crobison <chris.m...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Django FileBrowser" group.
To view this discussion on the web visit https://groups.google.com/d/msg/djangofilebrowser/-/F9K1oLNKioIJ.
To post to this group, send email to djangofi...@googlegroups.com.
To unsubscribe from this group, send email to djangofilebrow...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/djangofilebrowser?hl=en.

Dheeraj Sayala

unread,
Aug 24, 2012, 1:41:07 AM8/24/12
to djangofi...@googlegroups.com, Mark Reuten
Django's FileSystemStorage doesn't overwrite the file, but creates a unique name by appending _count to the filename until the generated filename doesn't exist. FileBrowser seems to overwrite existing file by moving the uploaded file to the existing file.


From my experience, file overwriting is not something users will want by default. I think it should be left to the storage class to find a name and store the file. We can always override get_available_name of the storage class to get any behavior we want.

patrick kranzlmueller

unread,
Sep 6, 2012, 6:06:05 AM9/6/12
to djangofi...@googlegroups.com, Mark Reuten
good point, thanks.

I just added a setting OVERWRITE_EXISTING which is currently set to
"True" in order to be backwards-compatible.

best,
patrick


2012/8/24 Dheeraj Sayala <dhe...@agiliq.com>:
> https://groups.google.com/d/msg/djangofilebrowser/-/66Z4rkZrQXQJ.
Reply all
Reply to author
Forward
0 new messages