pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccp999 <ccp...@hotmail.com>
Subject Re: How to use pivot post to upload file in form of MULTIPART_FORM_DATA_TYPE?
Date Wed, 13 Jun 2012 01:21:52 GMT
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 =
FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new FileDataBodyPart("thumbnail", file)); 
String s = c.resource("").path("upload")
.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!

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.

View raw message