MER-C / wiki-java

A MediaWiki bot framework in Java
GNU Affero General Public License v3.0
66 stars 58 forks source link

Image upload fails #184

Closed exander77 closed 3 years ago

exander77 commented 3 years ago

I reproduce the same error as Commonist when uploading images (upload method):

{"code":"missingparam","info":"The \"token\" parameter must be set.","*":"See somewhere something..."}

https://commons.wikimedia.org/wiki/Commons_talk:Commonist

easty77 commented 3 years ago

I had been happily using V0.30 of wiki-java since 2013 until I hit this problem uploading svg images. Hoping it would fix it I upgraded to the latest version, but same problem. This leads me to suspect that the issue is not with wiki-java API but with the Wikipedia/Wikimedia implementation that is being called.

exander77 commented 3 years ago

@easty77 Yes, they probably deprecated some APIs and wiki-java was not prepared for it.

michal-josef-spacek commented 3 years ago

So issue is in creating of POST parameters. Output is something like this:

------------NEXT PART----------
"Content-Disposition: form-data; name=\""
filesize"

Content-Type: text/plain; charset=UTF-8

5007661

------------NEXT PART----------
"Content-Disposition: form-data; name=\""
offset"

Content-Type: text/plain; charset=UTF-8

0

I am proposing change to something like:

------------NEXT PART----------
Content-Disposition: form-data; name="filesize"
Content-Type: text/plain; charset=UTF-8

5007661

------------NEXT PART----------
Content-Disposition: form-data; name="offset"
Content-Type: text/plain; charset=UTF-8

0
michal-josef-spacek commented 3 years ago

PR in https://github.com/MER-C/wiki-java/pull/185

easty77 commented 3 years ago

Fix works well for me regarding the missing token error. Thank you.

However for one of the 5 files I loaded to test I received the following error: error code="badupload" info="The file for "file" was only partially uploaded." xml:space="preserve" I have not seen this before and I was able to upload the file (svg) without issues using the Upload wizard.

I am calling the wiki-java API directly in a Java application.

michal-josef-spacek commented 3 years ago

@easty77 Which error? (I don't see any). And which tool you are using? (I am testing this in Vicuna)

easty77 commented 3 years ago

Edited answer above with requested details.

michal-josef-spacek commented 3 years ago

@easty77 It is a random image or concrete image type or file?

easty77 commented 3 years ago

https://commons.wikimedia.org/wiki/File:Owner_Rolf_Siepmann.svg

michal-josef-spacek commented 3 years ago

@easty77 I uploaded normally by development version of Vicuna (https://commons.wikimedia.org/wiki/File:Owner_Rolf_Siepmann2.svg)

easty77 commented 3 years ago

ok, let's forget about that glitch. I'll report back if I experience such issues more regularly. It certainly seems that the missing token issue has now been fixed. Thanks.

michal-josef-spacek commented 3 years ago

@MER-C Could we merge this PR (#185)?

MER-C commented 3 years ago

It's merged. If this issue persists please reopen.