Resolved in wikitech-l!

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jan Luca
Gesendet: Dienstag, 20. Oktober 2009 10:03
An: 'MediaWiki API announcements & discussion'
Betreff: Re: [Mediawiki-api] Problem with Upload API

Hi,

I have seen that I cannot upload per URL because I (my bot) haven't the
upload_by_url right. So I change my tool to the file argument:

$new_file = <Name of the target file>;
$url = <URL of the source file>;
$desc = <Description>;
$filename = <Name of the source file>;
$this->server = 'commons.wikimedia.org';

$connect = fsockopen ($this->server, 80, $err_num, $err_str, 10);
                
$token = $this->get_token();
                
$file = file_get_contents( $url );
$query = "POST
/w/api.php?format=php&action=upload&filename=".urlencode($new_file)."&token=
".urlencode($token)."&file=".urlencode($filename)."&comment=".urlencode($des
c)." HTTP/1.1
Host: ".$this->server."
Cookie: ".$cookies."
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7)
Gecko/20041107 Firefox/1.0
Content-Type: multipart/form-data
Content-Length: ".strlen($file)."
Content-Disposition: form-data; name=\"".$filename."\";
filename=\"".$filename."\"

".$file."
\r\n\r\n";
fputs ($connect,$query);

But now I get this error: array(1) { ["error"]=>  array(2) { ["code"]=>
string(12) "missingparam" ["info"]=>  string(69) "One of the parameters
sessionkey, file, url, enablechunks is required" } }

What is wrong?

Viele Grüße
Jan

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Bryan Tong
Minh
Gesendet: Montag, 19. Oktober 2009 20:06
An: MediaWiki API announcements & discussion
Betreff: Re: [Mediawiki-api] Problem with Upload API

On Mon, Oct 19, 2009 at 8:02 PM, Bryan Tong Minh
<[email protected]> wrote:
> Hi,
>
>
> On Mon, Oct 19, 2009 at 7:39 PM, Jan Luca <[email protected]> wrote:
>
>> Content-Type: application/x-www-form-urlencoded
>> Content-Length: ".strlen($message)."
>
> File uploads should always be encoded in multipart/form-data format.
>
Ignore that, I see you are using upload by url. Somehow the async mode
is triggered, but I don't see how. I will see when I can investigate
this.


Bryan

_______________________________________________
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


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

Reply via email to