Hi Greg,

To my knowledge it shouldn't be necessary to do a lot of encoding. I could be 
wrong though. I recently sent this message containing code how to send a 
multipart response: http://markmail.org/message/lnkgviksr5kr2hkf

Kind regards,
Geert

-----Oorspronkelijk bericht-----
Van: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] Namens Jason Hunter
Verzonden: dinsdag 19 april 2011 2:18
Aan: General MarkLogic Developer Discussion
Onderwerp: Re: [MarkLogic Dev General] Multipart HTTP POST

There's nothing built into MarkLogic that writes the multipart/form-data POST 
body for you.  You're going to have to format the POST message yourself 
according to RFC 1867 with things like the boundary lines and content-type 
headers.

(Note that if you do that, it'd be a great thing to add to the commons shared 
code repository on developer.marklogic.com.)

The complexity you're going to hit is how to send a binary file in the middle 
of an otherwise text POST body.  MarkLogic doesn't make that easy.  You can set 
a binary() node as the POST body, but for RFC 1867 you'll have to construct 
that binary() node yourself from a sequence of strings (boundary lines and 
headers) and raw bytes (actual payload).  If you're willing to base64 or hex 
encode the binary file as a string and decode it on the server, then the 
MarkLogic side will be easy.  It's just one big string to manage.

But if you can't do that, how would you construct the single binary() node 
that's the combination of strings surrounding another binary() node?  The nasty 
hack that I envision is you'd want to start with the string, get its hex or 
base64 encoded value, append the binary's hex or base 64 encoded value, then 
convert that encoded byte sequence back to a binary() and POST that.

-jh-

On Apr 18, 2011, at 1:36 PM, Murray, Gregory wrote:

> 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
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to