Thanks Bartosz...
Trying that,

  files = {'file': open(LOCAL_FILENAME,'rb')}
values = {'action': 'upload', 'format':'json','filename':fn, 'comment':'test upload', 'text':'{{OGL2}}\n\nPlease contact [[User:Storkk]] if there are issues','token':csrftoken}
  r = requests.post(baseurl, files=files, data=values)

Doesn't even return JSON, but the HTML API help.
Likewise with

  with open(LOCAL_FILENAME,'rb') as f:
      CONTENTS = f.read()
  files = {'file': CONTENTS}

same thing.

storkk

Quoting Bartosz Dziewoński <[email protected]>:

You should probably just pass the file to the requests library and have it do all the work, like setting up multipart/form-data and Content-Disposition. I don't often write Python, but this looks like the right approach: http://stackoverflow.com/a/22567429

--
Bartosz Dziewoński

_______________________________________________
Mediawiki-api mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api




_______________________________________________
Mediawiki-api mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to