Hello,
I am posting a JSON doc to a RESTXQ function from XForms and trying to set a Content-Disposition header to trigger a file download. Is this possible to do without first saving the JSON doc as a file? Right now, the RESTXQ function returns the correct headers, but does not force a file download dialog.
Thanks in advance!
Tim
--
Query:
xquery version "3.1";
module namespace wrap = "http://example.org/wrap";
declare
%rest:path("/wrap")
%rest:POST("{$data}")
%output:method("json")
function wrap:process(
$data as node()
) as item()* {
let $name := data($data/data/upload/file/@name)
let $json := json-to-xml($data/data/upload/file)
let $header :=
``[attachment; filename="`{$name}`";]``
return
(
<rest:response>
<http:response
status="200" message="OK">
<http:header
name="Content-Type"
value="application/json"/>
<http:header
name="Content-Disposition"
value="{$header}"/>
</http:response>
</rest:response>,
<map xmlns="http://www.w3.org/2005/xpath-functions">
<map
key="Profile">
<array
key="resourceTemplates">{$json}</array>
<string
key="title">Wrapper_Profile</string>
<string
key="id">Wrapper:Profile:BF2</string>
<string
key="description">Profile wrapper for resource templates</string>
<string
key="author">Wrapper</string>
<string
key="schema">https://ld4p.github.io/sinopia/schemas/0.0.9/profile.json</string>
<string
key="date">{current-dateTime()}</string>
</map>
</map> => xml-to-json() => parse-json() => serialize(map {'method': 'json', 'use-character-maps' : map {'/' : '/'}})
)
};
--
Tim A. Thompson
Discovery Metadata Librarian
Yale University Library