Open GoogleCodeExporter opened 9 years ago
Original comment by yan...@google.com
on 2 Oct 2012 at 1:43
Is there a current work around for this in this lib?
Original comment by chris.mark.jenkins@gmail.com
on 16 Apr 2013 at 7:23
I needed the same feature for my application, and I ended up modifying the
MultipartRelatedContent class, following the RFC 2388 specifications
(http://tools.ietf.org/html/rfc2388). It is not thoroughly tested and probably
not the best implementation possible, but I've been using it since months and
it's working correctly with 'multipart/form-data' requests.
You can find it in my Android utils library, released under Apache 2.0 license
(so you can freely use and modify it), here:
https://github.com/Luluvise/droid-utils/blob/master/src/com/github/luluvise/droi
d_utils/network/MultipartFormDataContent.java
Original comment by fas...@gmail.com
on 17 Apr 2013 at 12:34
Thanks for sharing. Would you be interested in contributing to the library
directly?
For details about the process for contributing, please take a look here:
https://code.google.com/p/google-http-java-client/wiki/BecomingAContributor#Cont
ributor_License_Agreements
Original comment by yan...@google.com
on 17 Apr 2013 at 2:01
Yeah, of course. Will do!
Original comment by fas...@gmail.com
on 18 Apr 2013 at 4:15
[deleted comment]
I have made several improvements to my class and made it usable with the latest
version (1.15.0-rc) of the library by directly subclassing MultipartContent.
I will soon submit the patch for code review, at the moment the class can be
found here:
https://github.com/Luluvise/droid-utils/blob/master/src/com/google/api/client/ht
tp/MultipartFormDataContent.java
Note that the MultipartContent class itself can sometimes be successfully used
to construct "multipart/form-data" content.
That can be accomplished in the following way:
MultipartContent content = new MultipartContent();
content.setMediaType(new HttpMediaType("multipart/form-data"));
Part part = new Part(*yourHttpContent*);
HttpHeaders headers = new HttpHeaders(); // or retrieve existing headers
headers.setAcceptEncoding(null);
headers.set("content-disposition", "form-data; name=\"field\"");
part.setHeaders(headers);
content.addPart(part);
However, by doing so some specifications in the RFC2388 have to be implemented
manually, such as the mandatory header "content-disposition" for each part, and
some redundant headers are appended for every part even though they are not
needed (i.e. content-length).
Original comment by fas...@gmail.com
on 17 Jun 2013 at 3:51
Hi,
The code proposed seems OK for a workaround. I also did my own workaround
delegating on org.apache.http.entity.mime.MultipartEntity. (See attached).
However, in order to build it into the real google-http-java-client, I am
missing:
- Code reuse as class inheritance, not as copy-paste. I would expect something
like a MultipartContent base class, with specific MultipartRelatedContent and
MultipartFormDataContent child classes.
- I think for MultipartFormDataContent it is interesting to accept data
objects, as JsonHttpContent does.
Original comment by titogar...@gmail.com
on 19 Jun 2013 at 11:06
Attachments:
As a workaround I used Marco's MultipartFormDataContent class, worked well for
me for creating attachments in Salesforce :) For this:
http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert
_update_blob.htm
Hopefully a class for posting form-data would be part of the lib some day.
Thanks
Original comment by ale...@yoxel.com
on 3 Jul 2013 at 1:26
Original issue reported on code.google.com by
titogar...@gmail.com
on 9 May 2012 at 11:41