function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
d.popovd.popov 

Method does not exist or incorrect signature: [System.HttpRequest].setBody(Blob)

Is it possible to download binary files?

If not, what solution to use for downloading to an external service


 

public Blob fileBody{get;set;}  

 

OAuth oa = new OAuth();

oa.setService('AmazonS3');

Http h = new Http();

HttpRequest req = new HttpRequest();

req.setMethod('PUT');

req.setEndpoint('https://amazons3.....');

req.setBody(fileBody);

try {

HTTPResponse res = http.send(req);   

System.debug(res.toString());

System.debug('STATUS:'+res.getStatus());

System.debug('STATUS_CODE:'+res.getStatusCode());

catch(System.CalloutException e) {

}  


 

Navatar_DbSupNavatar_DbSup

Hi,

 

filebody should not be blob type it should be string type.setbody will take a string parameters instead of blob type. You can convert blob to string through tostring() method.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

d.popovd.popov

It's work!

This method has upload limit 3M?

Alex.AcostaAlex.Acosta

Thats your total heap size limit within apex....

 

For more info on govenor limits:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

d.popovd.popov

How to upload files to an outside service, larger than 3M?

And this error on uploading:  Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 156.719KB 

d.popovd.popov

Сan you help me?

UVUV

You will have to optimize the view state to avoid this limit hit.

go through this and see best practices to optimize view state-

http://wiki.developerforce.com/page/An_Introduction_to_Visualforce_View_State

 

Also,there are some old posts from people had faced the same issue and few of them are here for your reference-

http://boards.developerforce.com/t5/Visualforce-Development/Error-Maximum-view-state-size-limit-128K-exceeded-uh-oh/td-p/87434

http://boards.developerforce.com/t5/New-to-Cloud-Development/ViewState-Problem-in-Salesforce-Production/td-p/283647

d.popovd.popov

I solved the problem with view state:

Body = null;

 

But the problem with downloading large files have remained:

System.CalloutException: Exceeded max size limit of 3000000 with request size 7179162


UVUV

There are request and response limits in salesforce and these cannot be bypassed.You will need to  limit the amount of data you are sending in a request, and use multiple posts to process data in parts.

GuyClairboisGuyClairbois

I'm getting the same error, but the current governor limits state that the maximum size for callout request/response is 6MB (it was recently increased I belive) (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm)

 

Anybody has a clue if this update is still due? Or is it listed incorrectly in the gov limits? 

Thanks,

Guy

 

 

Alex.AcostaAlex.Acosta

This may be updates with the new limit for Spring 12. I believe all servers have not recieved the upgrade yet but will be shortly if I'm not mistaken.

sapthagiri_186sapthagiri_186

Hey,

 

How did you resolve this issue. I have been trying to do so and I have a requirement where I can attach a file to a record being entered. It is been successful only for files of size lesser than 135kb and for larger files, it started showing Maximum view state size limit (135KB) exceeded and in the backend, the file is being attached to the record.

 

So, how to overcome this.

 

Best Regards