You need to sign in to do that
Don't have an account?
sending a non-ascii file via Http POST
Hello All,
I need to send an uploaded document to a third party webservice. I can send text files fine. But all other file types are getting corrupted.
I have been struggling for the past 3 weeks with this problem . I ahve tried several variations like Content-Transfer-Encoding : base64 and sending the
EncodingUtil.base64Encode(blob) with no luck. Is there some thing I am missing. I need to be ableto send pdfs, images, doc files.
Please help.
Thanks
Gopi
String response; String boundary = 'AaBbCcX30'; String m_URL = 'some url'; String content = 'Content:\r\n--' + boundary + '\r\nContent-Disposition:form-data;name="' + p_fileName + '";filename="'+p_fileName+'"\r\n'; content +='Content-Type:' + p_fileContentType + ',charset=ISO-8859-1,*,utf-8\r\n'; content +='Content-Transfer-Encoding: binary\r\n\r\n'; content += p_fileBlob +'\r\n\r\n'; content += '--'+boundary+'--\r\n'; System.debug(p_fileBlob.size()+'content ' + content); Http m_http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(m_URL); req.setHeader('Content-Type','multipart/form-data;boundary='+boundary); req.setMethod('POST'); req.setBody(content); HttpResponse m_httpResp = null; m_httpResp = m_http.send(req); m_strHttpResp = m_httpResp.getBody();
Hi Gopi,
Where you able to solve the problem. Can you post the complete working code.
Thanks a lot.
I am working this same issue as well and have run in to the same problem. My motivation to manually formulate the POST message for the file is that it seems like the only way to associate any server response processing with a file upload. If someone knows of a way to async capture the response after using a standard FORM/submit action that would be helpful as well.
Hello,
Were you able to send a non-ascii file (file size of more than 1MB) to a third party server successfully? I am having the same difficulty in forming the multipart request with POST and sending a non ascii file of size more than 1MB. I really appreciate if you can share your experience and may be sample code on this.
Thanks,
- Murthy
Based on Winter11 release they lifited file size limit (I have to verify the release notice once again).I am not abble to do that non-acsici file.I will post some sample code.
thanks
Hello
I need to send a text file using HTTP post.
Could you please share the code .
Thanks in advance
guys anyone able to solve this? I'm also having trouble with uploading files other than text files to external service. :( .. help
I am facing the same issue, any success? Can anyone please share the code.
So this is not possible: http://boards.developerforce.com/t5/Apex-Code-Development/Image-upload-using-multipart-form-data/m-p/243345/highlight/true
Please promote this idea: https://sites.secure.force.com/success/ideaView?c=09a30000000D9xtAAC&id=08730000000Kr80AAC
Yes its not possible yet :( ...
Hi guys I need some comments over my solution
http://enreeco.blogspot.it/2013/01/salesforce-apex-post-mutipartform-data.html
I've meed up with Blob, Encoding/Decoding and HttpResponse
Tell me what you think!
Hi Enreeco,
I am currently working on post a document to third party server through http.
I have one small question regarding the final code that posted in your blog.
You have declared and initialized the body as body+='Content-Disposition: ....
Where you have used this 'body' variable again.
Do I need to modify the bodyEncoded like the below ?
String bodyEncoded = body+EncodingUtil.base64Encode(file.body);
Please help me ...I have posted the same question in your blog also.
Thanks,
Indy.