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 (Performance Edition) I deployed to, 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). It seems like it's trying to redirect me to the login page, so it's not authenticating properly. I've determined that this is because the web request needs a session ID, whereas the mobile SDK authentication uses oauth, and only has an access token.
Either route working would be a viable solution (although the latter method is preferred for larger files)