• SFDC Mobile
  • 0 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2

Hi All,


I am trying to upload file through Rest API. i am able to upload and extract text files properly but if i upload any other file format (pdf,doc ,ppt or any image) , the file uploads fine but if i try to open that file it won't open( error message : file is broken , or the pdf is blank). It seems the file body i am sending is not properly encoded for other file formats.

Below is my code which i am using to upload files

String ObjectName = input.filename;
System.debug('ObjectName' + ObjectName);
Blob BodyContent=input.fileBody;
String DocBody = BodyContent.toString();
// String DocBody = EncodingUtil.base64Encode(BodyContent);
// String DocBody = EncodingUtil.urlEncode(bodyContent.toString(), 'UTF-8');
// String DocBody1 =
System.debug('DocBody' + DocBody);
Integer bodyLength =DocBody.length();
System.debug('bodyLength ------------->' + bodyLength );

String url6=input.StorageURL;
Http h6 = new Http();

HttpRequest req6 = new HttpRequest();
req6.setEndpoint(url6 + '/' + input.containerName + '/'+input.objectPath + '/' + ObjectName );//

// System.debug('Request object is----------->' + req6);
HttpResponse res6;
res6 = h6.send(req6);
if i upload a file directly to storage size is 15Kb but if i upload through API file size is showing 24 KB.

Please let me know do i need to encode the file body or am i missing any thing.

I have tried with encloding also but still no luck

Quick response would be appreciated!!

  • September 14, 2010
  • Like
  • 0

We've created a custom field and picklist that has the different steps in our proposal process. I'd like to create a formula that will mimic the existing stage duration one that is standard in Salesforce.  Does anyone have some direction for me on this?  We have professional I believe (the one under enterprise).


Thanks so much!