How to produce multipart/mixed results with RESTXQ?

Monday, 21 February 2022 · 2 messages · last reply 22 Feb 2022
IL
Imsieke, Gerrit, le-tex21 Feb 2022 23:07 #
I was faintly hoping that a sequence will be magically output as multipart/mixed with appropriate part content types when I annotate it with %rest:produces("multipart/mixed"): declare %rest:GET %rest:path("/test") %rest:produces("multipart/mixed") function my:test-multipart() { (<ok/>, json:serialize(map{'some':'json'})) }; But the response header says "Content-Type: application/xml", and the result is
<ok/>
{
   "some": "json"
}
Are there some other functions or annotations or rest:response elements that I can use in order to get multipart/mixed correctly assembled? Bonus: With the possibility to add file names to each chunk? Gerrit
CG
Christian Grün22 Feb 2022 15:32 #
Hi Gerrit, As for now, multipart support is only available for requests (multipart/mixed [1], multipart/form-data [2]). Responses are limited to single parts as multipart data had not been considered in the RESTXQ specification. It would be reasonable to also choose sequences for multipart/mixed and maps for multipart/form-data (with filenames as keys). I’ll have some more thoughts on that. Best, Christian [1] https://docs.basex.org/wiki/RESTXQ#Multipart_Types [2] https://docs.basex.org/wiki/RESTXQ#HTML_Form_Fields
Quoted text · le-tex · 28 lines
On Mon, Feb 21, 2022 at 11:07 PM Imsieke, Gerrit, le-tex <gerrit.imsieke at le-tex.de> wrote: > > I was faintly hoping that a sequence will be magically output as > multipart/mixed with appropriate part content types when I annotate it > with %rest:produces("multipart/mixed"): > > declare > %rest:GET > %rest:path("/test") > %rest:produces("multipart/mixed") > function my:test-multipart() { > (<ok/>, json:serialize(map{'some':'json'})) > }; > > But the response header says "Content-Type: application/xml", and the > result is > > <ok/> > { > "some": "json" > } > > Are there some other functions or annotations or rest:response elements > that I can use in order to get multipart/mixed correctly assembled? > Bonus: With the possibility to add file names to each chunk? > > Gerrit

⚡Generated with XQuery