I'm trying to upload a file to a wiki using Mathematica's URLFetch
. Some preliminary work is required - one needs to log in to the wiki, obtain an edit token, and exchange some cookies with the wiki server. URLFetch
can handle all of that. But then for the actual file upload, the MediaWiki API (e.g. http://www.mediawiki.org/wiki/API:Upload) specifies that one has to use the POST method with Content-Type=multipart/form-data
, but the Mathematica implementation of multipart within URLFetch
seems to be incomplete.
The Mathematica documentation of the option "MultipartData"
of URLFetch
says only:
to upload multipart data, each part must be of the form
{name, mimeType, {bytes}}
, where{bytes}
is a list of bytes
This suggests that in the "Content-Disposition" header of each part of a multipart request, a name can be specified as in:
Content-Disposition: form-data; name="file"
but there seems to be no way to also specify a filename, as in
Content-Disposition: form-data; name="file"; filename="Apple.gif"
Finally, the MediaWiki API requires that a file name be specified; see e.g. the example of a multipart request at the very bottom of http://www.mediawiki.org/wiki/API:Upload (and when I try to upload a file without specifying a filename, the wiki server sends back an error message).
So my question: Is there a more complete implementation of the MultiPart protocol with URLFetch
?
Comments
Post a Comment