restxq multipart/mixed application/octet-stream

Tuesday, 19 July 2016 · 1 message
CG
Christian Grün19 Jul 2016 19:00 #
Hi Jiri, Quite some time has passed, and it may well be that you don’t remember your question on the list… But I wanted to report that BaseX should now be capable of sending and receiving multipart data with binary contents [1]: Multipart data will now be transfered as Base64 if it contains non-ASCII characters. A new snapshot is available [2]; BaseX 8.5.2 will be released around end of July. Cheers Christian [1] https://github.com/BaseXdb/basex/issues/1203 [2] http://files.basex.org/releases/latest
Quoted text · Christian Grün · 87 lines
On Tue, Oct 20, 2015 at 9:39 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Thanks for the helpful example. I have added a GitHub issue [1], and > we'll try to fix it soon. > Christian > > [1] https://github.com/BaseXdb/basex/issues/1203 > > > > On Tue, Oct 20, 2015 at 9:25 AM, Dolejsi Jiri <Dolejsi at mail.ctk.cz> wrote: >> First I will try to send simple Binary document with 2 bytes(0xff0xff): >> let $req := >> <http:request method="POST"> >> <http:body media-type="audio/mpeg" method="raw"></http:body> >> </http:request> >> return http:send-request($req,"http://127.0.0.1:8984/insert-doc", bin:hex("ffff")) >> >> into restxq method: >> >> declare %rest:path("insert-doc") %rest:POST("{$doc}") function nib:insert-doc($doc as xs:base64Binary) as item() >> { >> <result>{$doc}</result> >> }; >> >> Response is: <result>//8=</result> >> Thi is correct: bin:to-octets(xs:base64Binary("//8=")) => 255 255 >> (NOTE: if I embed document inside body <http:body ...>{ bin:hex("ffff")}</http:body>, it will return <result>Ly84PQ==</result>) >> >> >> Then try to send multipart/mixed, first document xml, second binary: >> let $req := >> <http:request method="POST"> >> <http:multipart media-type="multipart/mixed" boundary="abc"> >> <http:body media-type="text/xml" method="xml"></http:body> >> <http:body media-type="audio/mpeg" method="raw"></http:body> >> </http:multipart> >> </http:request> >> return http:send-request($req,"http://127.0.0.1:8984/insert-doc-m", (<newsItem>info about audio</newsItem>,bin:hex("ffff"))) >> >> into restxq method: >> declare %rest:path("insert-doc-m") %rest:POST("{$doc}") function nib:insert-doc-m($doc as item()+) as item() >> { >> let $xml := $doc[1] >> let $bin := $doc[2] >> return <result>{$bin}</result> >> }; >> Response is: <result>? >> </result> >> >> (NOTE: when I do not specify attribute boundary, then it will provoke java exception) >> >> >> -----Original Message----- >> From: Christian Grün [mailto:christian.gruen at gmail.com] >> Sent: Monday, October 19, 2015 2:32 PM >> To: Dolejsi Jiri >> Subject: Re: [basex-talk] restxq multipart/mixed application/octet-stream >> >>> So I used multipart/mixed type. But mp3 part is damaged, after received by restxq function. >> >> Ok; so it doesn't matter if you use file:write-text or file:write-binary? >> >> Could you please provide us with a little example request that we can use for debugging? >> >> >> >>> -----Original Message----- >>> From: Christian Grün [mailto:christian.gruen at gmail.com] >>> Sent: Monday, October 19, 2015 2:27 PM >>> To: Dolejsi Jiri >>> Subject: Re: [basex-talk] restxq multipart/mixed >>> application/octet-stream >>> >>>> When I send this same value as application/octet-stream document into >>>> restxq method declare %rest:path("test2") %rest:PUT("{$mrs-doc}") >>>> function nib:insert-doc2($doc as item()) as empty-sequence() { >>>> file:write-binary("d:\abc.bin", $doc) }; It functions ok. >>> >>> So I assume you already found the answer? >>> >>> >>> Odesílatel tohoto e-mailu informuje adresáta, že ČTK vyžaduje k platnosti právního jednání písemnou formu s výjimkou jednání realizovaného prostřednictvím elektronických systémů ČTK (Fotobanka, Videobanka, Protext, NewsMarket, Infobanka). >>> >>> Dále informuje adresáta, že smlouva s ČTK nemůže být uzavřena, pokud není výslovná shoda o všech jejích náležitostech. ČTK si vyhrazuje právo ukončit jednání o uzavření smlouvy kdykoli, a to z jakéhokoliv důvodu nebo i bez uvedení důvodu. Obsahuje-li tento e-mail nabídku, ČTK vylučuje přijetí nabídky s dodatkem či odchylkou. >>> >>> Pokud je tento mail kvitancí ve smyslu § 1949, odst. 1 zák. č. 89/2012 Sb., ČTK výslovně sděluje, že kvitance o zaplacení jakékoliv splátky dluhu neznamená, že byla současně zaplacena jakákoliv část téhož dluhu splatná dříve, a kvitance o splátce jistiny neznamená, že bylo zaplaceno také příslušenství pohledávky.

⚡Generated with XQuery