xf:upload with multipart/form-data example?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

xf:upload with multipart/form-data example?

Mark Waschkowski
Hi Aaron,

OK, this is the second try, google ate my first :(

Anyway, a colleague of mine is now doing the file upload and noticed
that with your test case the upload comes through as

  'Content-Type: multipart/related;'

rather than

  'Content-Type: multipart/form-data;'

which is what we would have expected. Our upload library that we
typically use (commons upload from apache) only supports 'Content-
Type: multipart/form-data;' Is multipart/related correct? If so, do
you know of a java library that can support this content type?

Thanks a lot!

Mark

PS. relates to:
http://groups.google.com/group/mozilla.dev.tech.xforms/browse_thread/thread/34ae403d08e8187e/903ca90f5cb8d778?lnk=gst&q=mwaschkowski&rnum=1#903ca90f5cb8d778

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: xf:upload with multipart/form-data example?

Aaron Reed
Hi Mark,

Sorry, I was wrong.  The testcase I pointed you to wasn't a form-data
testcase.  It was using @method="multipart-post" instead of
"form-data-post" in the submission.  For an example of a form-data-post
form, you could try the testsuite testcase:
http://www.w3.org/MarkUp/Forms/Test/XForms1.0/Edition2/Chapt11/11.5/11.5.a.xhtml

--Aaron

mwaschkowski wrote:

> Hi Aaron,
>
> OK, this is the second try, google ate my first :(
>
> Anyway, a colleague of mine is now doing the file upload and noticed
> that with your test case the upload comes through as
>
>   'Content-Type: multipart/related;'
>
> rather than
>
>   'Content-Type: multipart/form-data;'
>
> which is what we would have expected. Our upload library that we
> typically use (commons upload from apache) only supports 'Content-
> Type: multipart/form-data;' Is multipart/related correct? If so, do
> you know of a java library that can support this content type?
>
> Thanks a lot!
>
> Mark
>
> PS. relates to:
> http://groups.google.com/group/mozilla.dev.tech.xforms/browse_thread/thread/34ae403d08e8187e/903ca90f5cb8d778?lnk=gst&q=mwaschkowski&rnum=1#903ca90f5cb8d778
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: xf:upload with multipart/form-data example?

Mark Waschkowski
Hi Aaron,

Ok no probs, and thanks for the example, which is great for text/plain
uploads. But (and you knew there was a but) I still need an example of
using form-data-post with a binary file - I'm trying to upload a jpg
and keep getting the name of the file, not the binary content :(

Here is what I'm getting when I post now:
POST /action?upload~.x=y HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.5) Gecko/20070713 Firefox/2.0.0.5
Accept: text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/temp/upload.xhtml
Content-Length: 761
Content-Type: multipart/form-data;
boundary=---------------------------106903106331484
-----------------------------106903106331484
Content-Disposition: form-data; name="file"
Content-Type: text/plain; charset=UTF-8

file:///C:/Documents%20and%20Settings/Mark%20Waschkowski/Desktop/downloads/15683-h.jpg
-----------------------------106903106331484
Content-Disposition: form-data; name="fileDestination"
Content-Type: text/plain; charset=UTF-8

filesystem
-----------------------------106903106331484
Content-Disposition: form-data; name="relativePath"
Content-Type: text/plain; charset=UTF-8

reports/spills
-----------------------------106903106331484
Content-Disposition: form-data; name="parentNodeXPath"
Content-Type: text/plain; charset=UTF-8

documents/reports/report[1]
-----------------------------106903106331484--


I don't want that file name, just the binary content...if you have a
working example for binary content with form-data-post I'm sure I can
figure out the rest, but my example is either broken or there is still
a problem with the upload control...

Best,

Mark


On Aug 29, 12:53 pm, Aaron Reed <[hidden email]> wrote:

> Hi Mark,
>
> Sorry, I was wrong.  The testcase I pointed you to wasn't a form-data
> testcase.  It was using @method="multipart-post" instead of
> "form-data-post" in the submission.  For an example of a form-data-post
> form, you could try the testsuite testcase:http://www.w3.org/MarkUp/Forms/Test/XForms1.0/Edition2/Chapt11/11.5/1...
>
> --Aaron
>
> mwaschkowski wrote:
> > Hi Aaron,
>
> > OK, this is the second try, google ate my first :(
>
> > Anyway, a colleague of mine is now doing the file upload and noticed
> > that with your test case the upload comes through as
>
> >   'Content-Type: multipart/related;'
>
> > rather than
>
> >   'Content-Type: multipart/form-data;'
>
> > which is what we would have expected. Our upload library that we
> > typically use (commons upload from apache) only supports 'Content-
> > Type: multipart/form-data;' Is multipart/related correct? If so, do
> > you know of a java library that can support this content type?
>
> > Thanks a lot!
>
> > Mark
>
> > PS. relates to:
> >http://groups.google.com/group/mozilla.dev.tech.xforms/browse_thread/...


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: xf:upload with multipart/form-data example?

Aaron Reed
Hi Mark,

Here is a form that uploads an image with @method = form-data-post.

Let me know if it doesn't work for you,
--Aaron

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xforms="http://www.w3.org/2002/xforms" xml:lang="en">
   <head>
     <title>Upload an Image</title>
     <xforms:model xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="i_model">
       <xforms:instance xmlns="">
         <mail xmlns="">
           <attachment xsi:type="xsd:base64Binary" filename=""
mediatype=""/>
         </mail>
       </xforms:instance>
       <xforms:submission id="submit1" ref="/mail/attachment"
action="http://xformstest.org/cgi-bin/echo.sh" method="form-data-post"/>
     </xforms:model>
   </head>
   <body>
     <div xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <xforms:upload ref="/mail/attachment" mediatype="image/*"
incremental="true">
         <xforms:label>Select image:</xforms:label>
         <xforms:filename ref="@filename"/>
         <xforms:mediatype ref="@mediatype"/>
       </xforms:upload>
       <br/>
       <xforms:submit submission="submit1">
         <xforms:label>Submit</xforms:label>
       </xforms:submit>
     </div>
   </body>
</html>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms