Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#11055 closed (fixed)

ImageField uploads fail at r10717

Reported by: Tim Graham Owned by: Armin Ronacher
Component: File uploads/storage Version: master
Severity: Keywords:
Cc: Christian Hammond, eallik@…, varikin@…, albrecht.andi@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


When uploading an image in the admin I get the error: Upload a valid image. The file you uploaded was either not an image or a corrupted image. r10717 seems to have introduced the bug as r10716 works fine.

Attachments (1)

11055-rewind-file.patch (485 bytes) - added by Armin Ronacher 10 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 10 years ago by Christian Hammond

Cc: Christian Hammond added

comment:2 Changed 10 years ago by anonymous

I get the same problem, might have to do with - which is the fix I was updating for.

comment:3 Changed 10 years ago by Armin Ronacher

milestone: 1.1
Owner: changed from nobody to Armin Ronacher

I have a fix for that. The behavior for rewinding slightly changed and i have to figure out how the old code was supposed to rewind.

comment:4 Changed 10 years ago by Armin Ronacher

Okay. The best fix is attached as diff. Previously the InMemoryUploadedFile did the rewinding, but for consistency with temporary file uploads I proposed adding the rewind to the upload finish handler.

comment:5 Changed 10 years ago by Armin Ronacher

Has patch: set
Needs tests: set

Changed 10 years ago by Armin Ronacher

Attachment: 11055-rewind-file.patch added

comment:6 Changed 10 years ago by Karen Tracey

Problem is broader than ImageFields, I hit it with general file upload (where I validate the content as part of cleaning the uploaded file field). I've not looked at the code at all but the attached patch does fix it for my case as well. (I'm surprised we don't have a test that caught this -- I could have sworn I've seen a test that validates uploaded content is as expected.)

comment:7 Changed 10 years ago by Armin Ronacher

The attached patch fixes it for any kind of upload. It was a mistake made in the refactoring of the file upload system. The patch attached reverts the old (and intended) behavior, just that the seek is now in a different function for consistency with the other upload backends.

comment:8 Changed 10 years ago by Erik Allik

Cc: eallik@… added

comment:9 Changed 10 years ago by John Shimek

Cc: varikin@… added

comment:10 Changed 10 years ago by Andi Albrecht

Cc: albrecht.andi@… added

comment:11 Changed 10 years ago by Jacob

Triage Stage: UnreviewedAccepted

comment:12 Changed 10 years ago by Jacob

Resolution: fixed
Status: newclosed

Fixed in [10739].

comment:13 Changed 8 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top