Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#11055 closed (fixed)

ImageField uploads fail at r10717

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


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 mitsuhiko 7 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by chipx86

  • Cc chipx86 added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 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 7 years ago by mitsuhiko

  • milestone set to 1.1
  • Owner changed from nobody to mitsuhiko

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 7 years ago by mitsuhiko

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 7 years ago by mitsuhiko

  • Has patch set
  • Needs tests set

Changed 7 years ago by mitsuhiko

comment:6 Changed 7 years ago by kmtracey

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 7 years ago by mitsuhiko

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 7 years ago by RaceCondition

  • Cc eallik@… added

comment:9 Changed 7 years ago by varikin

  • Cc varikin@… added

comment:10 Changed 7 years ago by aalbrecht

  • Cc albrecht.andi@… added

comment:11 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:12 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [10739].

comment:13 Changed 5 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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