0

When I get a binary file from server I access it via r.content. The problem is I want to turn this binary to image and then send it to browser as below:

i = Image.open(StringIO(r.content))

But calling this would return the following error:

AttributeError('JpegImageFile instance has no __call__ method',) 

or for example:

AttributeError('PngImageFile instance has no __call__ method',)

This code is from python documentation

Alireza
  • 6,497
  • 13
  • 59
  • 132
  • Can you show the rest of your code? how you read the image? and store that? Most likely sounds that the problem is because of your image name, perhaps it conflict with other objects within your code! – Mazdak Feb 07 '15 at 08:58
  • Not sure about your specific issue, but have you considered just downloading the image to a temporary file and then opening it? – Sean Azlin Feb 07 '15 at 08:59
  • The storage server is somewhere else. I just upload to that storage server via `requests.post` @KasraAD, @SeanAzlin – Alireza Feb 07 '15 at 09:30

1 Answers1

0

I solved it with send_file in flask.helpers as below:

my_file = StringIO(r.content)
send_file(my_file)

;-)

Alireza
  • 6,497
  • 13
  • 59
  • 132