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
Pedram SalehPedram Saleh 

Trying to download file via REST API and hitting heap size limit on sandbox, but not on enterprise org. Direct download doesn't seem to work either

I'm developing a React Native app and downloading library files into the app's file system. I have an apex class that converts the file to base64, and returns that as the result. I then call that in my app via REST API, and save the resulting file.
This was working fine when running the app against the org I developed on (Enterprise Edition), but when running it against a sandbox we deployed to (Performance Edition), I get an error that I've exceeded the heap size limit if the file is larger than a few MB. This is with the exact same files that worked fine on my enterprise org. Why would this be the case? The docs say that there's a 6MB heap size limit, but that doesn't seem to apply to my enterprise org and it's not clear why.
I'm trying to get around this whole thing by just downloading the file directly using /sfc/servlet.shepherd/version/download/<ContentVersionID> but that only seems to work in a browser and not via a REST API call in my app. When testing it in my app and in rest explorer, it just returns some code within a script tag as the result (with a HTTP response code of 200 OK).
So basically I'm stuck. Either route working would be a viable solution (although the latter method is preferred for larger files)