tested on: eXist 6.4.0
When trying to PUT or POST a file as multipart/form-data, an error is thrown:
2026-02-10 18:16:32,973 [qtp1906335777-3102] WARN (RESTServer.java [writeResultXML]:2159) - org.xml.sax.SAXException: exerr:ERROR Unable to encode string value: Underlying channel has been closed [at line 145, column 26, source: /db/system/repo/roaster-1.11.0/content/body.xqm]
org.exist.xquery.XPathException: exerr:ERROR Unable to encode string value: Underlying channel has been closed [at line 145, column 26, source: /db/system/repo/roaster-1.11.0/content/body.xqm]
This is the affected code:
let $names := request:get-uploaded-file-name($name)
let $data := request:get-uploaded-file-data($name)
let $sizes := request:get-uploaded-file-size($name)
(https://github.com/eeditiones/roaster/blob/c1e9ca5d1bd1ce298808f3685fa6a37fde9d0f40/content/body.xqm#L144C1-L146C64)
Changing the order does not change the error; removing the call to -data() does not throw an error.
Workaround, tested on eXist 6.4.0, is to add a function call that returns a new sequence, e.g.
let $data := request:get-uploaded-file-data($name) ! util:base64-decode(.)
(Wild guess: could this be related to lazy variable evaluation?)
tested on: eXist 6.4.0
When trying to
PUTorPOSTa file asmultipart/form-data, an error is thrown:This is the affected code:
(https://github.com/eeditiones/roaster/blob/c1e9ca5d1bd1ce298808f3685fa6a37fde9d0f40/content/body.xqm#L144C1-L146C64)
Changing the order does not change the error; removing the call to
-data()does not throw an error.Workaround, tested on eXist 6.4.0, is to add a function call that returns a new sequence, e.g.
(Wild guess: could this be related to lazy variable evaluation?)