Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, to a format for flickr's API?

Eg:

{'photo': ('image.jpg', <InMemoryUploadedFile: image.jpg (image/jpeg)>)}

Upload API: https://www.flickr.com/services/api/upload.api.html

Error Code

<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="fail">
    <err code="4" msg="Filesize was zero" />
</rsp>
like image 913
user3613750 Avatar asked Apr 05 '16 04:04

user3613750


1 Answers

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.

like image 129
spiffyman Avatar answered Sep 24 '22 06:09

spiffyman