I'm trying to save a jpg image from a Flask app form. The following code works fine:
blob = request.files[canvas_key]
blob.stream.seek(0)
data = blob.stream.read()
string_io = cStringIO.StringIO(data)
string_io has type <cStringIO.StringI object at 0x10bf2bf10>
.
Yet when I try: Image.open(string_io)
, I get this error: IOError: cannot identify image file
.
Using stream.seek(0)
seems to solve this problem for other people, but in my case it hasn't.