Hi,
this seems related to https://github.com/BaseXdb/basex/issues/1203
Problem 1: When setting Content-Transfer-Encoding manually (via
<http:header>), it will appear twice in the request that is sent
Problem 2: I cannot override base64 because it happens automatically
based on the content I am sending and for some reason the web server
that receives this request does not recognize the base64 encoding
correctly
Regards,
Max
2017-01-30 15:35 GMT+01:00 Maximilian Gärber <mgaerber@arcor.de>:
> Hi,
>
> I can't figure out how to send a file in binary (not base64) when
> using multipart [1]
>
> On the body, I've tried method="basex" because the docs says this
> would write raw bytes to the request
>
> Regards,
> Max
>
>
> [1]
>
> declare function _:send-multipart($url, $file-name, $path) as item()* {
>
>
> let $uri := file:path-to-uri($path || $file-name)
> let $type := fetch:content-type($uri)
>
> let $binary := file:read-binary($path || $file-name)
> let $boundary_id := concat("batch_", random:uuid())
>
> let $req :=
> <http:request method="post" send-authorization="false"
> override-media-type="text/plain">
>
> <http:header name="Accept" value="application/json"/>
> <http:header name="Accept-Encoding" value="gzip, deflate"/>
>
> <http:multipart media-type="multipart/form-data"
> boundary="{$boundary_id}">
>
> <http:header name="Content-Transfer-Encoding" value="binary"/>
> <http:header name="Content-Disposition" value="form-data;
> name='FILE'; filename='{$file-name}'"/>
> <http:header name="Content-Type" value="{$type}"/>
>
> <!-- method="basex" method="adaptive" ? -->
> <http:body media-type="application/octet-stream" method="binary">
> {$binary}
> </http:body>
>
> </http:multipart>
> </http:request>
>
> let $resp := http:send-request($req, $url)
> return json:parse($resp[2])
>
> };