API talk:Upload

Flag: Don't overwrite existing file
It would be nice if there was a flag that said: Don't overwrite any already existing file. This could help in preventing errors in bots, especially as Special:Upload mangles the filename a bit, so it's not entirely trivial to make sure a file of a given name does not already exist. --Tbleher 20:20, 14 February 2008 (UTC)
 * Good one. I'll keep this in mind. --Catrope 21:32, 17 February 2008 (UTC)

File Contents?
Could you be more specific on the file contents? Is it just a bunch of bytes, UUEncoded, HEX, or what?


 * Assuming you mean direct upload, the file content should be sent as part of the request in multipart/form-data format, so essentially yes, just a bunch of bytes. Gurch 05:03, 30 October 2009 (UTC)

I'm trying to do this with curl, but am having no luck with any kind of file content inclusion. Can you give an example? Here are some things I'm trying: curl -b cookies.txt -d "action=upload&filename=exported.xml&file=$(cat exported.xml)&format=xml&token=$UPLOADTOKEN" http://lookipedia.net/w/api.php

curl -b cookies.txt -d "action=upload&filename=exported.xml&file= text &format=xml&token=$UPLOADTOKEN" http://lookipedia.net/w/api.php

curl -b cookies.txt -d "action=upload&filename=exported.xml&file=TEST&format=xml&token=$UPLOADTOKEN" http://lookipedia.net/w/api.php

curl -b cookies.txt -d "action=upload&filename=exported.xml&file=@exported.xml&format=xml&token=$UPLOADTOKEN" http://lookipedia.net/w/api.php In all cases I get this error:  Pjrich 17:48, 10 October 2011 (UTC)

Upload by URL
I'm not having much more luck than you with uploading by URL. I did try retrieving httpstatus using the session key, and got the following result:

{u'upload': {u'content_length': u'5706', u'loaded': 5706, u'upload_session_key': u'12345'}}

But the file wasn't actually uploaded, and I don't see any way of determining what went wrong. --R&#39;n&#39;B 18:45, 29 October 2009 (UTC)


 * It was broken before, was fixed in r58337 -- Gurch 05:11, 30 October 2009 (UTC)

Unrecognized value for parameter action: upload
I'm trying to upload a file via wget. Login and fetching token is OK, but on upload...

wget --load-cookies cookies.txt -O upload.xml \ --post-data "action=upload&filename=atlasmw-export.xml&file=[content goes here]&token=$EDITTOKEN" \ $API

I get this:

&lt;error code=&quot;unknown_action&quot; info=&quot;Unrecognized value for parameter &amp;#039;action&amp;#039;: upload&quot; xml:space=&quot;preserve&quot;&gt;

Documentation says:

api.php ? action=upload & filename=Test.txt & file=file_contents_here & token=+\

What's wrong? Using MediaWiki 1.15.1. Jpatokal 03:32, 20 November 2009 (UTC)
 * It's a 1.16 feature. Max Semenik 05:45, 20 November 2009 (UTC)

overwrite: text parameter ignored
is there a good reason the text parameter is ignored when overwriting an existing file? imho it would make sense to overwrite the description, too. -- ∂ 23:55, 23 April 2010 (UTC)

Mediawiki Push Extension
Is anyone here familiar with the MW Push extension?

Trying to get it to work and not having much success.

The extension author has been less than helpful:

"In any case, I don't know what your issue is, so can't really help you any further."

I keep getting the same error:

Could not obtain an edit token on the target wiki

After reading and reading I suspect it might have something to do with the API Upload.

Any thoughts?