On Wed, Feb 1, 2012 at 5:22 PM, Robert Vogel <vogel@hallowelt.biz> wrote:

Hi!

 

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.

 

When I try to upload a base64 encoded file via the API (i.e. a JPEG) I just get a file with the base64 string (i.e. plaintext with base64 code) written to the MediaWiki file repo.

 

Any hints?

Are you using a client that generates a MIME multipart POST request for you, or are you doing that yourself? If you're generating one yourself, you can simply use the Content-Transfer-Encoding: base64 header to tell the web server that the file is base64-encoded. If you're using a library or client that builds an HTTP request for you, you'll probably have to decode the base64 encoding and hand the raw file contents to the library/client.

Roan