Hi, i am requiring a way to upload (large) files (without loading them all into the memory) via the API and have an status callback which calls at every written chunk (update progress bar).
The only way i found to do this via requests is using a multipart message.
The python module _requeststoolbelt for example supports this, but the encoding part isn't that complex, so it could be done without additional required libs, too (FE, see end of this article: http://blog.thesparktree.com/post/114053773684/the-unfortunately-long-story-dealing-with ).
The problem with this approach is we need to set the content_type. imgurpythons _Client.makerequest function doesn't support setting headers.
So i suggest adding a new function to imgurpython supporting streaming uploads with callbacks and add the code from _Client.makerequest, or (and i think this is the better way) add an "additional headers" parameter to _Client.makerequest which updates the headers returning from the _prepareheaders call and just use _Client.makerequest in the new "streaming_uploadfile" function.
I think such feature would be nice to have in the library, so let me know what you think about it.
I would be willing to submit a patch if the changes are wanted.
Hi, i am requiring a way to upload (large) files (without loading them all into the memory) via the API and have an status callback which calls at every written chunk (update progress bar).
The only way i found to do this via requests is using a multipart message.
The python module _requeststoolbelt for example supports this, but the encoding part isn't that complex, so it could be done without additional required libs, too (FE, see end of this article: http://blog.thesparktree.com/post/114053773684/the-unfortunately-long-story-dealing-with ).
The problem with this approach is we need to set the content_type. imgurpythons _Client.makerequest function doesn't support setting headers.
So i suggest adding a new function to imgurpython supporting streaming uploads with callbacks and add the code from _Client.makerequest, or (and i think this is the better way) add an "additional headers" parameter to _Client.makerequest which updates the headers returning from the _prepareheaders call and just use _Client.makerequest in the new "streaming_uploadfile" function.
A short example using requests_toolbelt with the additional_header approach: https://gist.github.com/SleepProgger/a6ca9cc15e3277f4e17a
I think such feature would be nice to have in the library, so let me know what you think about it. I would be willing to submit a patch if the changes are wanted.