Form with an upload field

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

Form with an upload field

Xavier Méhaut
Hello,
I would like to know how I can handle on the client side a formular with a file upload field type (

<input type="file" name="datafile" size="40"> in html for instance)...
I expect to use the FileUpload extension for doing this, but I don't know how to do it on the client side
regards
Xavier
Reply | Threaded
Open this post in threaded view
|

Re: Form with an upload field

Thierry Boileau-2
Hello Xavier,

actually the fileupload library is intended for the parsing of multipart requests. It is only usefull on server side.

You can use the apache httpclient library (in addition with the org.apache.httpmime and org.apache.james.mime4j libraries), in order to achieve what you need:

        BasicHttpEntityEnclosingRequest httppost = new BasicHttpEntityEnclosingRequest( "POST", "http://localhost:8182/testFileUpload");

        // Get stream from file
        FileInputStream fileStream = new FileInputStream( new File("/path/to/file.txt"));
        InputStreamBody streamBody = new InputStreamBody( fileStream, "text/plain", "file.txt");

        // Add a string
        StringBody comment = new StringBody( "A binary file of some kind", Charset.forName("UTF-8"));
        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("comment", comment);
        reqEntity.addPart("bin", streamBody);

        httppost.setEntity( reqEntity);

Best regards,
Thierry Boileau
Hello,
I would like to know how I can handle on the client side a formular with a file upload field type (

<input type="file" name="datafile" size="40"> in html for instance)...
I expect to use the FileUpload extension for doing this, but I don't know how to do it on the client side
regards
Xavier

Reply | Threaded
Open this post in threaded view
|

Re: Form with an upload field

Xavier Mehaut
thx thierry ; i ll try tomorrow instead if the ftp solution i started to use
regards

Envoyé de mon iPhone

Le 28 juil. 2010 à 22:42, Thierry Boileau <[hidden email]> a écrit :

Hello Xavier,

actually the fileupload library is intended for the parsing of multipart requests. It is only usefull on server side.

You can use the apache httpclient library (in addition with the org.apache.httpmime and org.apache.james.mime4j libraries), in order to achieve what you need:

        BasicHttpEntityEnclosingRequest httppost = new BasicHttpEntityEnclosingRequest( "POST", "http://localhost:8182/testFileUpload");

        // Get stream from file
        FileInputStream fileStream = new FileInputStream( new File("/path/to/file.txt"));
        InputStreamBody streamBody = new InputStreamBody( fileStream, "text/plain", "file.txt");

        // Add a string
        StringBody comment = new StringBody( "A binary file of some kind", Charset.forName("UTF-8"));
        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("comment", comment);
        reqEntity.addPart("bin", streamBody);

        httppost.setEntity( reqEntity);

Best regards,
Thierry Boileau
Hello,
I would like to know how I can handle on the client side a formular with a file upload field type (

<input type="file" name="datafile" size="40"> in html for instance)...
I expect to use the FileUpload extension for doing this, but I don't know how to do it on the client side
regards
Xavier

Reply | Threaded
Open this post in threaded view
|

RE: Form with an upload field

jlouvel
Administrator
In reply to this post by Xavier Méhaut

Hi Xavier,

 

There is currently no client-side support for file upload in Restlet Framework. You need to rely on a third-party library for now. See this RFE for current plans (scheduled for 2.1):

 

“Support composite representations”

http://restlet.tigris.org/issues/show_bug.cgi?id=71

 

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~
http://www.restlet.o​rg
Noelios Technologies ~
http://www.noelios.com

 

 

 

 

De : [hidden email] [mailto:[hidden email]] De la part de Xavier Méhaut
Envoyé : mercredi 28 juillet 2010 11:01
À : [hidden email]
Objet : Form with an upload field

 

Hello,
I would like to know how I can handle on the client side a formular with a file upload field type (

<input type="file" name="datafile" size="40"> in html for instance)...
I expect to use the FileUpload extension for doing this, but I don't know how to do it on the client side
regards
Xavier