Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Governor limits include

Maximum size of callout request or response (HTTP request or Web services call) - 3 MB

Does this include downloading files via HTTP from external servers? Will those files also be restricted to 3 megabytes?

share|improve this question
    
Best way to experiment this is to download the content and see whether it makes an API call?I dont think any API calls will be consumed and hence should not impact –  Mohith Kumar Feb 1 '13 at 11:09
add comment

1 Answer

If you are using an HTTPRequest from within Apex to retrieve or send a document to an external server, then yes, you are making a "callout", so the total payload of the HTTPRequest you are creating must be less than 3MB in size. See the HttpRequest docs, in particular the setBody, setBodyAsBlob, and setBodyAsDocument methods, for further proof of this. The corresponding get methods don't reiterate the 3MB limit, but I believe that the limit is the same regardless of whether you are sending or retrieving data.

Furthermore, this callout counts towards the total Heap Size limit for a single Apex transaction, which is 6MB (or 12MB if you're in Batch Apex, which can make callouts as well if properly annotated). So, for instance, if you need to post 3 large documents, say 1.9 MB a piece that you're generating from within Apex to an external service, you could do 3 separate callouts within a single Apex transaction, and you would presumably be at only around 5.7 MB for your total heap size, and since no single callout generated a request body of greater than 3 MB, you should be fine.

If you have control over the remote endpoint that you are downloading / posting files to, you might want to take a look at leveraging the getCompressed and setCompressed methods of the HttpRequest class - these allow you to apply gzip compression to the file you are either retrieving or posting, with the intention of the data later being extracted / expanded, once you are outside of the Apex transaction. This could help you avoid some of the heap size limits, if you are able to later extract the files from the zipped format.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.