Hi all!
May I request that some python sample code be posted uploading a local
file, ideally using the requests module (which seems to be relatively
canonical)? I don't think I'm the first to be stymied by mw:API:Upload
(cf. Boxsnake's 18-month old unanswered question at mw:API_talk:Upload
; also
http://stackoverflow.com/questions/33839706/simplest-way-to-upload-a-file-to-an-up-to-date-mediawiki-instance-with-python where the answer was essentially "give up and use a bot
framework").
Essentially, I cannot seem to avoid getting a "badupload_file"/"File
upload param file is not a file upload; be sure to use
multipart/form-data for your POST and include a filename in the
Content-Disposition header."
I am under the impression I am doing both of those things, my headers are:
{'Content-Type': 'multipart/form-data',
'Content-Disposition': 'form-data; name="file";
filename="storkk_test_upload1.jpg"',
'User-Agent': 'Drudgebane Storkksbot (contact [[C:User:Storkk]]) Based
on python requests/2.11.1',
'Connection': 'keep-alive',
'Content-Length': '93990',
'Cookie': 'forceHTTPS=true; commonswiki_BPsession=...(elided)...',
'Accept-Encoding': 'gzip, deflate',
'Accept': '*/*'}
The full code (with a slightly different filename test), trying a few
different things, is at http://pastebin.com/PxLk85mR
I would greatly appreciate some pointers on where I am going wrong.
Thanks for your time,
storkk
_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api