Roan, Brad, thanks for the quick reply.
A few words about the use case: my colleague has got a java applet that generates an image and provides this image as base64 encoded string via a javascript interface. His javascript code grabs this string and uses the "FormMultipart" class from Brion Vibbers SVGEdit extension (modules/ext.svgedit.formmultipart.js) to send a request to the MediaWiki API. The "Content-Transfer-Encoding: base64" is set. The file that is created in the MediaWiki repo is corrupted.
So long, thanks for the hints. We will keep them in mind.
---
Robert Vogel Social Web Technologien Softwareentwicklung Hallo Welt! - Medienwerkstatt GmbH
______________________________
Untere Bachgasse 15 93047 Regensburg
Tel. +49 (0) 941 - 66 0 80 - 198 Fax +49 (0) 941 - 66 0 80 - 189
www.hallowelt.biz vogel@hallowelt.biz
Sitz: Regensburg Amtsgericht: Regensburg Handelsregister: HRB 10467 E.USt.Nr.: DE 253050833 Geschäftsführer: Anja Ebersbach, Markus Glaser, Dr. Richard Heigl, Radovan Kubani
-----Ursprüngliche Nachricht----- Von: mediawiki-api-bounces@lists.wikimedia.org [mailto:mediawiki-api-bounces@lists.wikimedia.org] Im Auftrag von Brad Jorsch Gesendet: Mittwoch, 1. Februar 2012 18:00 An: MediaWiki API announcements & discussion Betreff: Re: [Mediawiki-api] API: Fileupload with base64 encoded data
On Wed, Feb 01, 2012 at 05:22:39PM +0100, Robert Vogel wrote:
Does anybody know if it is possible to upload a base64 encoded file via the API? I've already examined SVGEdit extension by Brion Vibber (http://www.mediawiki.org/wiki/Extension:SVGEdit) to get behind the api file upload magic. But as SVG is just text it doesn't quite fit to my use case.
Since HTTP POSTs may contain binary data, you can send the file without any special encoding. That would usually be the best thing to do.
Theoretically, if you really wanted to base64-encode it you could include a "Content-Transfer-Encoding: base64" header in the MIME part for the file data.[1] But PHP doesn't handle this correctly,[2] so in practice you'll probably need to use 8bit or binary encodings instead.
[1] See RFC 2388 section 3. https://www.rfc-editor.org/rfc/rfc2388.txt [2] https://bugs.php.net/bug.php?id=48219
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api