API talk:Upload

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] 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)

[edit] 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=<xml>text</xml>&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:

<error code="missingparam" info="One of the parameters sessionkey, file, url, statuskey is required"/>

Pjrich 17:48, 10 October 2011 (UTC)

[edit] 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'n'B 18:45, 29 October 2009 (UTC)

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

[edit] 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:

<error code="unknown_action" info="Unrecognized value for parameter &#039;action&#039;: upload" xml:space="preserve">


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)

[edit] 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)

[edit] 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?

[edit] Reverting to an earlier revision?

I'm not sure if this is the right place, but: Does anyone know if it's possible to revert to an earlier revision? A workaround using archived image URLs comes to mind, but the particular wiki has URL uploads disabled. --84.186.216.128 00:07, 24 February 2012 (UTC)

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox