When I posted the image load with StringIO, and usd the web.py to obtain the StringIO object, I could not open it with PIL. My POST code is:
# encoding:utf-8
import requests
from StringIO import StringIO
img = open('test.jpg').read()
img = StringIO(img)
files = {'img': img}
baseUrl = r'http://localhost:8080/test'
requests.post(baseUrl, files = files)
My Web.py files index.py
import web
from PIL import Image
urls = ('/test', 'Test')
class Test:
def GET(self):
pass
def POST(self):
data = web.input()
# How: Use PIL to open the data?
img = Image.open(StringIO(data.img)) # report error
Thks!