Discussion:
Client and "multipart/form-data"
Christopher Schmidt
2012-01-10 06:51:46 UTC
Permalink
Can anyone point me to an example of how to emulate this CURL call (using
the Jersey Client):

curl \
-F 'access_token=…' \
-F 'batch=[ \
{"method": "GET", "relative_url": "me"}, \
{"method": "GET", "relative_url": "me/friends?limit=50"} \
]'\
https://graph.facebook.com

It is of Content-Type: multipart/form-data

from the curl man page (-F parameter)

-F/--form <name=content>
(HTTP) This lets curl emulate a filled-in form in which a
user has pressed the submit button. This causes curl to
POST data using the Content-Type multipart/form-data
according to RFC 2388. This enables uploading of binary files
etc. To force the 'content' part to be a file, prefix the
file name with an @ sign. To just get the content part
from a file, prefix the file name with the symbol <. The
difference between @ and < is then that @ makes a file
get attached in the post as a file upload, while the < makes
a text field and just get the contents for that text
field from a file.

Thanks and regards
--
Christopher
twitter: @fakod
blog: http://blog.fakod.eu
Pavel Bucek
2012-01-10 10:38:44 UTC
Permalink
Hi Christopher,

please see tests for multipart-webapp sample (includes client calls):
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/samples/multipart-webapp/src/test/java/com/sun/jersey/samples/multipart/MultipartWebAppTest.java?rev=5587

Regards,
Pavel
Post by Christopher Schmidt
Can anyone point me to an example of how to emulate this CURL call
|curl \
-F 'access_token=…' \
-F 'batch=[ \
{"method": "GET", "relative_url": "me"}, \
{"method": "GET", "relative_url": "me/friends?limit=50"} \
]'\
https://graph.facebook.com|
It is of Content-Type: multipart/form-data
from the curl man page (-F parameter)
-F/--form <name=content>
(HTTP) This lets curl emulate a filled-in form in which
a user has pressed the submit button. This causes curl to
POST data using the Content-Type multipart/form-data
according to RFC 2388. This enables uploading of binary files
etc. To force the 'content' part to be a file, prefix
from a file, prefix the file name with the symbol <. The
get attached in the post as a file upload, while the <
makes a text field and just get the contents for that text
field from a file.
Thanks and regards
--
Christopher
blog: http://blog.fakod.eu
Christopher Schmidt
2012-01-11 11:57:23 UTC
Permalink
Thanks Pavel, that helped. Should have seen the multipart link on the
Jersey homepage :-)
Post by Pavel Bucek
Hi Christopher,
http://java.net/projects/jersey/sources/svn/content/trunk/jersey/samples/multipart-webapp/src/test/java/com/sun/jersey/samples/multipart/MultipartWebAppTest.java?rev=5587
Regards,
Pavel
Can anyone point me to an example of how to emulate this CURL call (using
curl \
-F 'access_token=…' \
-F 'batch=[ \
{"method": "GET", "relative_url": "me"}, \
{"method": "GET", "relative_url": "me/friends?limit=50"} \
]'\
https://graph.facebook.com
It is of Content-Type: multipart/form-data
from the curl man page (-F parameter)
-F/--form <name=content>
(HTTP) This lets curl emulate a filled-in form in which a
user has pressed the submit button. This causes curl to
POST data using the Content-Type multipart/form-data
according to RFC 2388. This enables uploading of binary files
etc. To force the 'content' part to be a file, prefix the
from a file, prefix the file name with the symbol <. The
get attached in the post as a file upload, while the <
makes a text field and just get the contents for that text
field from a file.
Thanks and regards
--
Christopher
blog: http://blog.fakod.eu
--
Christopher
twitter: @fakod
blog: http://blog.fakod.eu
Loading...