Trying to figure out how best to build interfaces that retrieve external files between 1-10 MB and display them in the UI.

Right now I have a Lightning Aura Component that calls a web service via HttpRequest and retrieves file metadata, so that users can browse externally stored files. A second HttpRequest allows the user to either preview or download these files, depending on file type. Both methods are synchronous currently.

This works, but the current version has to cap file sizes for preview/download at around 5.7 MB, based on the "Maximum size of callout request or response (HTTP request or Web services call)" governor limit of 6 MB.

We have also been concerned about the "Number of synchronous concurrent long-running transactions that last longer than 5 seconds for each org" governor limit, which we could easily hit if there are multiple users requesting files larger than 1 MB at the same time that other long-running synchronous processes are executing in our org.

Needless to say, I was enthused when I heard that asynchronous processing was coming to Aura Components in Summer '19 in the form of support for Continuations (see release notes). But as I began to test this, I realized my callouts were failing at much lower file size thresholds than 6 MB. Apparently continuations have specific limits listed in the Apex Developer Guide whereby callouts and responses can't exceed 1 MB. Bummer.

Is there a special architecture whereby I can retrieve files of up to 10 MB and display them in the UI, which can be deployed to users at scale?


No longer concerned about these types of synchronous concurrent transactions due to a Winter '20 change from Salesforce, Callouts Are Excluded from Long-Running Request Limit. While the file size cap of 6 MB is still a minor frustration, we no longer have to worry about hitting governor limits due to the volume of requests for external files.

1 Answer 1


If you go via apex, the heap limitations will apply.

The workaround is to do a callout from javascript. Yes you can do that.

By default, you can’t make calls to third-party APIs from client-side code. Add a remote site as a CSP Trusted Site to allow client-side component code to load assets from and make API requests to that site’s domain.

So if you do a callout from browser, its heap and cpu of device involved and should be alright.

That being said, the thing you have to worry about is, if its an authenticated call, then make sure you dont do a callout from browser passing username and password. Instead do a callout from apex to get access_token and then use that access_token to call 3rd party,

Src: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_api_calls_platform.htm

Not able to call Composite REST request from LWC

  • Thanks Pranay! I may face an uphill struggle trying to get this API CORS-enabled, which would be necessary to use the AJAX approach. But I agree this seems like a viable alternative, and your response gave me the impetus to look into it further. Commented Jun 10, 2019 at 16:49
  • 1
    Hi Matthew, did you get work around using js. If yes, could you please share more details on how to proceed.
    – Nayana
    Commented Mar 24, 2020 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .