Skip to content Skip to sidebar Skip to footer

How To Convert An Inmemoryuploadedfile In Django To A Fomat For Flickr Api?

I have a class that uploads a file to Flickr. The file is of type 'InMemoryUploadedFile'. I would like to know how to convert or pass the data in the 'InMemoryUploadedFile' file, t

Solution 1:

InMemoryUploadedFile is a wrapper around a file object. You can access the file object using the file attribute. So, in your example, try passing this to the Flickr API:

{'photo': my_in_memory_file.file}

If that doesn't work, please edit your question with more detail around the code you're using to submit the request.

Solution 2:

The data inside the InMemoryUploadedFile onbject was extracted and passed to Flickr succesfully via:

importStringIO
file.seek(0)
file_handle = StringIO.StringIO(file.read())
{'photo': ('image.jpg', file_handle)}

Thanks

Post a Comment for "How To Convert An Inmemoryuploadedfile In Django To A Fomat For Flickr Api?"