#10258 closed (fixed)
many files with the same file name cannot be saved correctly
Reported by: | liangent | Owned by: | duncan |
---|---|---|---|
Component: | File uploads/storage | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | ianschenck | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The current Django code add '_' to file name in order to avoid overwrite saved files.
However, if I save many files with the same file name, Django will add many '_'s.
If the file name is too long, file will be saved correctly, but path in database will be truncated.
/var/lib/python-support/python2.5/django/db/backends/mysql/base.py:83: Warning: Data truncated for column 'output' at row 1 return self.cursor.execute(query, args)
Then when I try to get that file according to the path saved in database, it will fail...
Attachments (3)
Change History (16)
comment:1 by , 16 years ago
milestone: | post-1.0 |
---|
comment:2 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
Is adding the creation timestamp to the filename a good solution for this?
comment:4 by , 16 years ago
I mean, that way multiple files with the same filename can be saved with different names keeping them short.
comment:5 by , 16 years ago
Timestamps could still be long. Appending a number to the end of a filename would be much better than more underscores, though.
Something like:
name
name_0
name_1
name_2
...etc
comment:6 by , 16 years ago
Cc: | added |
---|---|
Has patch: | set |
comment:7 by , 16 years ago
Owner: | changed from | to
---|
comment:8 by , 16 years ago
Needs tests: | set |
---|
Patch to the code looks fairly sensible to me. I think we could do with some more tests though.
by , 16 years ago
Attachment: | 10258.2.diff added |
---|
Added one more doctest which uploads 10 files and checks for their names.
comment:10 by , 16 years ago
by , 16 years ago
Attachment: | 10258-on-9160.diff added |
---|
Patch that applies when patch from #9610 has been applied before. Apart from that its identical to 10258.2.diff
comment:11 by , 15 years ago
milestone: | 1.1 → 1.2 |
---|
Punting to 1.2. For now, use a custom upload_to and/or override the storage engine's get_available_filename function.
comment:12 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Milestone post-1.0 deleted