See these threads.

Jason Dorsey | Engineering Intern
1233 West Loop South
Houston, TX 77027 USA
[email protected]<mailto:[email protected]>
www.attachmate.com<http://www.attachmate.com/>  |  
www.netiq.com<http://www.netiq.com/>

From: V SANTOSH PAVAN RAJU Bs [mailto:[email protected]]
Sent: Wednesday, June 13, 2012 9:34 AM
To: [email protected]
Subject: How to upload a file?

Hi,

In pivot can we have any Component to upload files (like csv).
I tried FileBrowser but it is not efficient. So is there any other way to 
upload files.

--
Thanks & Regards
B.S.V.S.Pavan Raju.
Skype: skype_pavan1
Hyderabad.

--- Begin Message ---
Hi,
I'm sorry but on Jersey I can't help you so much ...

On the server side (speaking absolutely from a personal and subjective
point of view) I'd not use Node.js, but instead other (more
JVM-centric) frameworks ... some week ago I discovered this (probably
the most jvm-centric framework closer to node.js):

http://vertx.io/

Otherwise I'd use Grails or Play (or Lift), or Wicket on the server
side ... all these should have utility classes for transformation of
pojo from/to json, xml, etc ...


One of the things I'd like to improve in Pivot (maybe for 2.1) is the
extensibility for our existing Serializers.
Ideas, comments, etc as always are welcome.


Hope this helps (at least a little).

Bye,
Sandro

--- End Message ---
--- Begin Message ---
Thanks Sandro,

Actually, I tried to use Jersey client to perform file upload but there is a
problem for the control name.
Node.js express server doesn't recognized the control name of the file to be
passed from Jersey.

let say you have a javascript html like this:

'<html>' + '<head>' + '<meta http-equiv="Content-Type" ' +
'content="text/html; charset=UTF-8" />' + '</head>' + '<body>' + '<form
action="/upload" enctype="multipart/form-data" ' + 'method="post">' +'<input
type="file" name="thumbnail" multiple="multiple">' + '<input type="submit"
value="Upload file" />' + '</form>' + '</body>' + '</html>';

and it will upload a file you selected to server but the equivalent Jersey
code failed to present the control name, in this case is "thumbnail" which
could cost some trouble from server side to retrieve the file.  I use a
non-standard way to resolve the issue.

My client side code like this:

import java.io.File file;
com.sun.jersey.api.client.Client c =
com.sun.jersey.api.client.Client.create(config);
FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new FileDataBodyPart("thumbnail", file));
String s = c.resource("127.0.0.1").path("upload")
.type(MediaType.MULTIPART_FORM_DATA)
.accept(MediaType.APPLICATION_JSON).post(String.class, form);

The reason I use Jersey because it also support java object marshaling to
Json or xml and unmarshaling.  So you can have Java web server and Pivot
client with Jersey being the middle man for the java POJO transferring.

Unfortunately, I added Node.js as the web server in between for doing other
jobs and that's I have the incompatibility.

Hope someone have a better solution!

Brendan

--
View this message in context: 
http://apache-pivot-users.399431.n3.nabble.com/How-to-use-pivot-post-to-upload-file-in-form-of-MULTIPART-FORM-DATA-TYPE-tp4021907p4021910.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

--- End Message ---
--- Begin Message ---
Hi Brendan,
sorry, this is an old question (look here for example:
http://apache-pivot-users.399431.n3.nabble.com/File-upload-per-rfc-1867-td2667943.html
) ... in short I think that the best option is to use some library to
simplify/implement the file upload in the full RFC way, using
something like the Apache HttpClient, and maybe even Apache Commons
FileUpload at Server-side.

Then, wrap it inside a PostQuery() , change the request mime type to
that required by your server, etc ... but at this point I don't know
if Pivot PostQuery add a great value to your request.

Some info here:
http://stackoverflow.com/questions/2304663/apache-httpclient-making-multipart-form-post


Probably File Upload (in a full rfc implementation) it's something
that we could try enhance in core Pivot (at least in Demos, or in a
wiki page), so if you have something to share with us, please do it.
But usually we don't want to introduce new dependencies, so we have to
see if/how to do (could be something for apache-extras).


Keep us updated.

Bye

--- End Message ---

Reply via email to