This may not be exactly what you are looking for, but what I have done with
some REST interfaces is actually include the binary data in a single XML file
that is being posted.
Below is an example of loading an image off the filesystem, converting it to
Base64 and including it in a JSON structure, then POSTing the payload to a web
service. On the service side I just convertit back from base 64 to binary. This
works fine in terms of speed and simplicity, and I don't have to deal with
multipart. Not sure if it applies to what you are doing though.
let $src-filename := "Desert.png"
let $src-img-data :=
xs:base64Binary(xdmp:document-get("C:\Users\Public\Pictures\Sample
Pictures\Desert.png"))
let $payload := fn:concat('{
"something": "hello",
"srcFilename": "', $src-filename, '",
"srcImgData": "', $src-img-data, '"
}')
return xdmp:http-post("http://myendpoint:8180/services/imagething",
<options xmlns="xdmp:http">
<data>{$payload}</data>
<headers>
<content-type>application/json</content-type>
</headers>
</options>)
> From: [email protected]
> To: [email protected]
> Date: Mon, 18 Apr 2011 20:36:04 +0000
> Subject: [MarkLogic Dev General] Multipart HTTP POST
>
> I need to send an HTTP POST where the data includes multiple string
> parameters but also a binary file. How can I do this kind of
> multipart/form-data POST using xdmp:http-post?
>
> Thanks,
> Greg
>
> Gregory Murray
> Digital Library Application Developer
> Princeton Theological Seminary
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general