get multipart entry of file upload (RESTXQ)
Friday, 23 September 2016 · 3 messages
MG
Maximilian Gärber23 Sep 2016 10:07 #
Hi,
I can't find where I would access the other entries returned by a file upload.
What gets sent is
-----------------------------175432198730168
Content-Disposition: form-data; name="file"; filename="base.png" Content-Type: image/png
‰PNG as base64...
----------------------------
The file is in the $file map but how can I get the Content-Type for example?
%rest:POST("{$post}")
%rest:form-param("file", "{$file}")Regards,
Max
CG
Christian Grün23 Sep 2016 10:11 #
Not possible right now, sorry… Unfortunately, this part has never been specified so far. I remember that, back then, I was asking for feedback on the "simple" solution we realized. As everyone seemed to be happy, we didn’t extend it.
It would be nice if we found a way to extend the current solution without endangering backward compatibility; suggestions are welcome.
Quoted text · Maximilian Gärber · 24 lines
On Fri, Sep 23, 2016 at 10:07 AM, Maximilian Gärber <mgaerber at arcor.de> wrote: > Hi, > > I can't find where I would access the other entries returned by a file upload. > > What gets sent is > > -----------------------------175432198730168 > Content-Disposition: form-data; name="file"; filename="base.png" > Content-Type: image/png > > ‰PNG as base64... > ---------------------------- > > > The file is in the $file map but how can I get the Content-Type for example? > > %rest:POST("{$post}") > %rest:form-param("file", "{$file}") > > > Regards, > > Max
MG
Maximilian Gärber23 Sep 2016 11:36 #
Hi,
as a workaround this is ok:
for $name in map:keys($file)
let $content := $file($name)
let $save := file:write-binary($file-path, $content)
let $local-uri := file:path-to-uri($file-path)
let $mime := fetch:content-type($local-uri)Regards,
Max
2016-09-23 10:11 GMT+02:00 Christian Grün <christian.gruen at gmail.com>:
Quoted text · Christian Grün · 33 lines
> Not possible right now, sorry… Unfortunately, this part has never been > specified so far. I remember that, back then, I was asking for > feedback on the "simple" solution we realized. As everyone seemed to > be happy, we didn’t extend it. > > It would be nice if we found a way to extend the current solution > without endangering backward compatibility; suggestions are welcome. > > > On Fri, Sep 23, 2016 at 10:07 AM, Maximilian Gärber <mgaerber at arcor.de> wrote: >> Hi, >> >> I can't find where I would access the other entries returned by a file upload. >> >> What gets sent is >> >> -----------------------------175432198730168 >> Content-Disposition: form-data; name="file"; filename="base.png" >> Content-Type: image/png >> >> ‰PNG as base64... >> ---------------------------- >> >> >> The file is in the $file map but how can I get the Content-Type for example? >> >> %rest:POST("{$post}") >> %rest:form-param("file", "{$file}") >> >> >> Regards, >> >> Max
Written for BaseX 8.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery