Maybe it is because it is marked as form-data, instead of as attachment.
Have you compared with a simple html upload form? I¹m sure that worked
just fine for me in the past..

Cheers,
Geert

On 11/26/15, 9:08 PM, "[email protected] on behalf
of Florent Georges" <[email protected] on behalf of
[email protected]> wrote:

>Hi,
>
>I have a problem with a form, that I could narrow down to the
>following.  It is a POST of type multipart/form data, sending one file
>part:
>
>    ------------------------------ed0cb8f98262
>    Content-Disposition: form-data; name="file"; filename="example.xml"
>    Content-Type: text/xml
>
>    <hello>World!</hello>
>
>    ------------------------------ed0cb8f98262--
>
>When I use `xdmp:get-request-field('file')` to get te value, it is
>returned as a document node containing one text node.  If I change
>`text/plain` to `application/octet-stream`, the value is a binary
>node.
>
>I would have expected a document node with an element `hello`.  The
>following query reproduces the problem (accessing and outputing a few
>key values, to double-check my environment):
>
>    xquery version "1.0-ml";
>
>    import module namespace admin = "http://marklogic.com/xdmp/admin";
>       at "/MarkLogic/admin.xqy";
>
>    declare namespace xdmp = "http://marklogic.com/xdmp";;
>    declare namespace mt   = "http://marklogic.com/xdmp/mimetypes";;
>
>    declare function local:type-from-filename($name as xs:string) as
>xs:string*
>    {
>       let $ext   := fn:tokenize($name, '\.')[fn:last()]
>       let $types := admin:mimetypes-get(admin:get-configuration())
>       return
>          $types[mt:extensions/data() = $ext]/mt:name
>    };
>
>    <fields version="{ xdmp:version() }">
>    {
>       for $name     in xdmp:get-request-field-names()
>       let $value    := xdmp:get-request-field($name)
>       let $filename := xdmp:get-request-field-filename($name)
>       return
>          <field>
>             <name>{ $name }</name>
>             <is-text>{ $value/node() instance of text() }</is-text>
>             <is-binary>{ $value/node() instance of binary() }</is-binary>
>             <filename type="{ local:type-from-filename($filename)
>}">{ $filename }</filename>
>             <content-type>{
>xdmp:get-request-field-content-type($name) }</content-type>
>             {
>                if ( $value instance of binary() ) then
>                   <value>...binary...</value>
>                else
>                   <value>{ $value }</value>
>             }
>          </field>
>    }
>    </fields>
>
>When called with the following CURL command (just put the above query
>on a HTTP app server, and adapt the user, password, and endpoint
>below):
>
>    curl -u user:pwd --digest \
>        -F "file=@.../example.xml;type=text/xml" \
>        http://localhost:8010/test/tools/fields
>
>it returns the following:
>
>    <fields version="8.0-4">
>       <field>
>          <name>file</name>
>          <is-text>true</is-text>
>          <is-binary>false</is-binary>
>          <filename type="application/xml">example.xml</filename>
>          <content-type>text/xml</content-type>
>          <value>&lt;hello&gt;World!&lt;/hello&gt; </value>
>       </field>
>    </fields>
>
>
>When called with the following CURL command (note the different
>type=):
>
>    curl -u user:pwd --digest \
>        -F "file=@.../example.xml;type=application/octet-stream" \
>        http://localhost:8010/test/tools/fields
>
>it returns the following:
>
>    <fields version="8.0-4">
>       <field>
>          <name>file</name>
>          <is-text>false</is-text>
>          <is-binary>false</is-binary>
>          <filename type="application/xml">example.xml</filename>
>          <content-type>application/octet-stream</content-type>
>          <value>...binary...</value>
>       </field>
>    </fields>
>
>Did I miss something?  Shouldn't I get an XML document node?
>
>Posted on SO as well, at http://stackoverflow.com/questions/33946268/.
>
>Regards,
>
>-- 
>Florent Georges
>http://fgeorges.org/
>http://h2oconsulting.be/
>_______________________________________________
>General mailing list
>[email protected]
>Manage your subscription at:
>http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to