XProc 3: form-data with file

62 views Asked by At

does someone have an idea how to handle form-data with file upload in XProc 3.0?

<p:variable name="headers" as="map(xs:string, xs:string)" select="map {
        'authorization': concat('Bearer ', $api-key),
        'content-type': 'multipart/form-data'
        }"/>
       
    <p:variable name="method" select="'POST'"/>
    <p:variable name="endpoint" select="'/files'"/>
    <p:http-request name="http-request" parameters="map {'accept-multipart':true()}">
        <p:with-input>
            <!-- ??? -->
            <p:document href="input/deu.txt" content-type="text/plain"/>
        </p:with-input>
        <p:with-option name="href" select="escape-html-uri(concat($base-uri, $endpoint))"/>
        <p:with-option name="method" select="$method"/>
        <p:with-option name="headers" select="$headers"/>
    </p:http-request>

cURL snippet


curl https://... \
  -H "Authorization: Bearer $API_KEY" \
  -F purpose="mypurpose" \
  -F file="@mydata.txt"

I want to upload files via an API with XProc 3.0 and MorganaXProc-IIIse-1.

0

There are 0 answers