0

I have 3 servers, at A server, I choose a image in the browser and POST it to the B server using urllib2, at B server,I get the image POST from A and make some changes to it, then POST to C server, C server will get the image and store it on the disk.

I use PIL to change the image at B, and post it to C. Question is I can't get the image in the request.FILES at C.

The solution I found is saving the edited image to the disk temporarily then open it and POST it.

Is there a way to POST a image processed by PIL and POST it?

Here is the wrong code:

bits = ''
for chunk in image.chunks():
    bits += chunk
im_tmp = Image.open(StringIO(bits))
im_res = ImageAPI.process(im_tmp, mode, width, height) 
# ImageAPI class packages the PIL methods
output = StringIO()
im_res.save(output, format='PNG')
contents = output.getvalue()
call(url_str=url, file_dict={'file':contents}) 
# call method packages the urllib2 methods
Jinvan
  • 33
  • 1
  • 6

0 Answers0