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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Governor limits prevent downloading files larger than 3 megabytes using HTTPRequest.

Is there any other way to download a file from an external resource using Apex or any other mechanism in the Salesforce backend?

share|improve this question
What exactly is your use case? Can you provide a link to the external resource in Visualforce or a custom field that points directly to it, instead of trying to funnel the data through APEX? – Michael Welburn Feb 1 '13 at 17:40
@Michael Welburn: I need to integrate Salesforce with an external service. At some point Salesforce will ask the service to perform data processing and that results in a file that can potentially be rather huge. Salesforce has to somehow get hold of that file. The most direct way is to just use HTTPRequest. – sharptooth Feb 4 '13 at 6:41
If you have control over the external system, one option is to have the external system use the Salesforce REST API to hand the data back to Salesforce. This could mean creating a new ContentVersion object or Attachment object, which then would be subject to much higher limits. There is some more info on that here:… – D.S. Apr 18 at 17:19

On the backend-side of things (Apex) there is no alternative. However, you could do a trick via Visualforce where you'd show a page that downloads the file for you, and then uploads it to the Controller (base64 encoded).

Still, the heap limit (6MB) applies so you won't be able to go really wild. Taking into account the base64 overhead (uses 4 bytes per 3 bytes, so 33% overhead) you can upload files of max 4.5MB. That is, if you can use the frontend at all, which sounds like it is not the case here...

share|improve this answer

Your Answer


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.