[jetty-users] uploading the file with httpclient

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

[jetty-users] uploading the file with httpclient

makc
Hi again, I am trying to reproduce this command:

curl -u [hidden email] -X PUT -F file=@/Users/makc/test/www.zip https://build.phonegap.com/api/v1/apps/504042

using blocking api, according to this http://www.eclipse.org/jetty/documentation/current/http-client-api.html

my code so far looks more or less like this http://hastebin.com/jacayinuba.avrasm but I am getting 500 error, while the curl command works as expected.

my concern is that I did not specify "file" part of -F, but Request.file does not have a parameter for that? How do I set it? Thanks.

_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] uploading the file with httpclient

makc
The hint seems to be this: "The POST request is sent with the application/x-www-form-urlencoded content type, and POST parameter values are automatically URL-encoded" while curl man page http://curl.haxx.se/docs/manpage.html#-F says -F "causes curl to POST data using the Content-Type multipart/form-data". So it looks like I need to change request content type. contentType parameter in Request.file seems to be mime type, actually. So I again is clueless where to specify it :(

_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: [jetty-users] uploading the file with httpclient

Simone Bordet-2
Hi,

On Mon, Aug 12, 2013 at 4:00 PM, Makc <[hidden email]> wrote:
> The hint seems to be this: "The POST request is sent with the
> application/x-www-form-urlencoded content type, and POST parameter values
> are automatically URL-encoded" while curl man page
> http://curl.haxx.se/docs/manpage.html#-F says -F "causes curl to POST data
> using the Content-Type multipart/form-data". So it looks like I need to
> change request content type. contentType parameter in Request.file seems to
> be mime type, actually. So I again is clueless where to specify it :(

At the moment we do not support multipart uploads out of the box.
Not all file uploads are uploaded via multipart :)

As a workaround, you have to manually produce the multipart content
with a custom ContentProvider.

In any case, please add a feature request to support a simpler way to
perform multipart uploads in HttpClient at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Jetty.

Thanks !

--
Simone Bordet
----
http://cometd.org
http://webtide.com
http://intalio.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.
_______________________________________________
jetty-users mailing list
[hidden email]
https://dev.eclipse.org/mailman/listinfo/jetty-users