To get base64 value use the xs:base64Binary() conversion function. xs:base64Binary( xdmp:get-document( $foo ) )
To convert to binary use binary { } constructor. binary { xs:base64Binary( xdmp:get-document( $foo ) ) } - Keith -----Original Message----- From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Murray, Gregory Sent: Tuesday, April 19, 2011 2:40 PM To: General MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Multipart HTTP POST On Apr 18, 2011, at 8:18 PM, Jason Hunter wrote: > 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. > I'd like to try that first, but how do I get the binary's base64-encoded value, when xdmp:base64-encode() only accepts a string? > 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. If I have to resort to this, how do I convert the base64 string to a binary? Thanks, Greg > > -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 NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general