1

I am passing some data as string from my Visualforce page to apex via apex function, I store that data by in attachment body through apex code. What is the maximum size of data that I can store in Attachment body via apex?

Will this have the same 2gb limit for Salesforce lightning as mentioned in documentation?

1 Answer 1

3

No. Because of the Heap Size limit, you will be limited to 6MB of data, 4.5MB if you have to base-64 encode the data. If you need larger file sizes, call the Chatter API directly by way of JavaScript.

3
  • 1
    And if you are using VF page, you can utilize JSForce library to post any sizes of attachments (which are up to 25 mbs)
    – kurunve
    Dec 4, 2020 at 14:57
  • I see, I am assuming heap size limit of 6MB will be a consideration when passing data from VF to apex of same size, but in my case I have to store one message at a time and then append to same file when next message arrives, would I be able to utilize all storage limit by following this saving data in a step by step approach? If yes, then limit would be 25 MB?
    – Badar
    Dec 7, 2020 at 5:46
  • @Badar The maximum string length is the same as the maximum heap size, so you will be limited to 6MB (technically 6,000,000 Unicode characters) before you will reach a hard limit. If you need more, consider using direct API calls, such as by using apex:remoteObjects or the REST API.
    – sfdcfox
    Dec 7, 2020 at 13:13

You must log in to answer this question.

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