File uploading to temp folder

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

File uploading to temp folder

ManiKanta G-2
Hi,
 
I've a Xforms document with a <xforms:upload ...> and I've written a REST service for uploading the file. 
 
REST service is receiving the request, but the file is getting uploaded to TOMCAT_HOME\temp folder.
Even I removed the submission element's resource value then also the uploading to temp file is happening (I don't know who is uploading behind). When I inspected the source code, the html <form..> tag's action is set to my application context path.
 
Files in my application:
apps\my-upload\page-flow.xml :
            xmlns:oxf="http://www.orbeon.com/oxf/processors">
 <page path-info="/my-upload/" view="view.xhtml" />
 <epilogue url="oxf:/config/epilogue.xpl"/>
</config> 
apps\my-upload\view.xhtml : http://pastie.org/409126.txt
 
In the above view.xhtml, the resource atrribute of submission is kept blank intentionally (actually it is http://localhost:8182/upload; my upload REST service)
 
 
Please let me know if I m doing some this wrong or if any one has succeeded in implementing the above, please share the code.
ManiKanta G
Twitter/manikantag
 


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: File uploading to temp folder

ManiKanta G-2
isn't it possible to upload (type: multipart/form-data) file just specifying REST service (without using xpl or URL generator) ?
 
I googled googled for file uploading in Orbeon with REST.... no clear sign... I end up writing my own REST service and it is accepting multipart/form-data type uploads and working correct.
 
But when used with Orbeon no luck. I m usig both 3.7beta1, nightly builds.
 
In nightly builds I hear multippart/form-upload is working fine. Yeah it is working fine but the temporary file path is only coming (used serialization="multipart/form-upload")
 
I need this for the client demo in the coming 2 days.
If some knows about this, I'll glad to hear from them
 
Thanks,
ManiKanta G


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: File uploading to temp folder

Jeroen Hoffman
Hi,

The xforms-upload example uses a bind with xs:anyURI which makes the selected file being uploaded to a temp directory.
You can also use xs:base64Binary which will make the file being embedded encodedly in the xml document.

More at http://www.orbeon.com/ops/doc/reference-xforms-guide#xforms-upload

Jeroen



ManiKanta G wrote:
isn't it possible to upload (type: multipart/form-data) file just specifying REST service (without using xpl or URL generator) ?
 
I googled googled for file uploading in Orbeon with REST.... no clear sign... I end up writing my own REST service and it is accepting multipart/form-data type uploads and working correct.
 
But when used with Orbeon no luck. I m usig both 3.7beta1, nightly builds.
 
In nightly builds I hear multippart/form-upload is working fine. Yeah it is working fine but the temporary file path is only coming (used serialization="multipart/form-upload")
 
I need this for the client demo in the coming 2 days.
If some knows about this, I'll glad to hear from them
 
Thanks,
ManiKanta G



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: File uploading to temp folder

Erik Bruchez
Administrator
In reply to this post by ManiKanta G-2
> isn't it possible to upload (type: multipart/form-data) file just  
> specifying REST service (without using xpl or URL generator) ?

Not sure I understand this question. Please clarify what you intend to  
do.

> In nightly builds I hear multippart/form-upload is working fine.  
> Yeah it is working fine but the temporary file path is only coming  
> (used serialization="multipart/form-upload")

multipart/form-data will serialize any field with xs:anyURI or  
xs:base64Binary type as a part. On the wire, the data is serialized  
and there should not be a reference to temporary files if the type is  
properly set.

If the receiving side is Orbeon Forms, then the request processor  
makes every uploaded file available as a temporary file again.

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: File uploading to temp folder

ManiKanta G-2
In reply to this post by Jeroen Hoffman
The xforms-upload example uses a bind with xs:anyURI which makes the selected file being uploaded to a temp directory.
You can also use xs:base64Binary which will make the file being embedded encodedly in the xml document.
 
Thanks Jeroen. I've used that but no luck as I need to upload to another folder, not to temp folder.
 
From the doc/spec, xml encoding is not preferable for larger size files, which results much more increase in size, and suggested to use multipart/related (as multipart/from-data is old one).
 
I've used xs:anyURI (which they suggested) and given url of the REST service (deals with the multipart/form-data upload) but the content type receing is application/xml (this should be when I use xs:base64Binary. Is n't is?)
 
ManiKanta G
Twitter.com/manikantag


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: File uploading to temp folder

ManiKanta G-2
In reply to this post by Erik Bruchez
Not sure I understand this question. Please clarify what you intend to do.
 
Please see the view.xhtml code in http://pastie.org/410080.txt
The submission resource is the REST service I wrote to handle the multipart/form-data (I've tested this by uploading a file using normal html form upload).
 
I've used <xforms:bind nodeset="file" type="xs:anyURI" /> too. Even then also I m getting media type as application/xml, and the REST service is returns bad request header. I suppose the media type should be multipart/form-data. Isn't it???
 
multipart/form-data will serialize any field with xs:anyURI or xs:base64Binary type as a part. On the wire, the data is serialized and there should not be a reference to temporary files if the type is properly set.

If the receiving side is Orbeon Forms, then the request processor makes every uploaded file available as a temporary file again.
What does this receiving side? If I got it correct, I m not using any Orbeon/XPL for uploading. Simple REST service.
 
I saw some replies from mailing list to use file serializer with url processer. I m trying to figer it out. Will this solves my problem? please share the way of doing so.
 
Thanks,
 
ManiKanta G


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: File uploading to temp folder

ManiKanta G-2
Below is the request body received by service:
POST /upload HTTP/1.1
Cookie: JSESSIONID=57CE3140873C75E43CEB9377C273C9C1
Content-Type: application/xml
User-Agent: Jakarta Commons-HttpClient/3.1
Content-Length: 520
<?xml version="1.0" encoding="UTF-8"?>
<file  xmlns:f="
http://orbeon.org/oxf/xml/formatting"
       xmlns:ev="
http://www.w3.org/2001/xml-events"
       xmlns:xforms="
http://www.w3.org/2002/xforms"
       xmlns:xhtml="
http://www.w3.org/1999/xhtml"
       xmlns:xs="
http://www.w3.org/2001/XMLSchema"
       xmlns:widget="
http://orbeon.org/oxf/xml/widget"
       xmlns:xxforms="
http://orbeon.org/oxf/xml/xforms"
   filename="LLP-SRS_Ver1-NIC.pdf"
   mediatype="application/download"
   size="1314486">
       file:/C:/Tomcat6/temp/upload__3efec1c_11fdfcc8ec5__7ffc_00000512.tmp
 </file>
Now I m trying to use the XPL to copy the temp file to the required location.
 
As far I know I need to use file serializer to read the above response and  copy to the required location:
 
 <p:processor name="oxf:file-serializer">
  <p:param name="instance" type="input"/>
 
  <p:input name="config">
   <config>
    <directory>file:///e:/docs_upload/</directory>
    <file>single-file-doc.html</file>
    <make-directories>true</make-directories>
    <append>false</append>
   </config>
  </p:input>
  <p:input name="data" href="#instance"/>
 </p:processor>
but I m not able to guess where do I need to place this. (I've tried this placing in the 3.7 beta1 bundled upload example's 'do-background-upload.xpl' file. but nothing happening).
 
Litter confusion! Even I removed all the files and just with the view.xhtml & page-flow.xml the file is uploaded to temp folder. how is this possible?
Am I making a BIG mistake some where?
 


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: File uploading to temp folder

Alessandro Vernet
Administrator
On Mar 7, 2009, at 4:04 AM, ManiKanta G wrote:

> Litter confusion! Even I removed all the files and just with the  
> view.xhtml & page-flow.xml the file is uploaded to temp folder. how  
> is this possible?
> Am I making a BIG mistake some where?

First, the support for file uploads with multipart/form-data has been  
implemented very recently. So you'll need a recent nightly build for  
this. With a nightly build, you can do it directly in XForms, with an  
<xforms:submission>.

Second, it is hard to get a clear picture of what you are doing and  
what goes wrong. Could you send us some code that runs in the XForms  
sandbox example? We don't need to have a real service on the other  
side to catch the file; you can do the submission to any web site and  
we can check the HTTP traffic to see if the right content is sent over  
the wire.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: File uploading to temp folder

ManiKanta G-2
I've mentioned the source file link in the above mail. Any way http://pastie.org/410080.txt is the link.


ManiKanta G
twitter.com/manikantag


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: File uploading to temp folder

Alessandro Vernet
Administrator
ManiKanta G-2 wrote
I've mentioned the source file link in the above mail. Any way
http://pastie.org/410080.txt is the link.
Sorry, I missed it. You just need:

1) To add a serialization="multipart/form-data" to your <xforms:submission>.
2) To add a <xforms:bind nodeset="/file" type="xs:anyURI"/>.

And here is modified file.

Alex