I have two components,
- Aura (Parent) --- Showing fields of cases and have create case button
- LWC (Child component) --- Using input tag, I am accepting csv and excel of maximum size 3.5 mb. After reading a file using sheet.js in LWC, I am showing a table as well as firing an event to send whole JSON structure of excel sheet to the parent aura component.
Scenario: I am uploading a file (CSV or Excel allowed) from MAC laptop that have 10,000 rows. File size shown on Mac is: 369 KB. Now as I click on save button to create a case, I am sending the JSON structure of excel I received from LWC component and saving it as txt file attached to case. Also, I am not using CHUNK to upload put that json into text file.
But I saw, the file size shown by salesforce for that 10,000 records json txt file is 2.6 MB and the heap size I found at the end of the transaction is 5.2 MB (Close to 6MB). Without uploading a file, maximum heap size is around 1MB.
How can the size of the txt file is increased so high? Also, It there any way I can reduce heap size error.
If anyone wants me to have code, child(LWC) + Parent (Aura) component, please let me know.
Note: I just now pasted a json to character count online for the json, total count of characters: 2689192. Now if I consider one character = 1 byte in salesforce, then on converting 2689192 to MB result 2.6 MB which salesforce is showing size of the file. Am I right that 1 character = 1 byte ?
If yes, then how I can reduce heap size OR is there is any way I can use some javascript remoting in aura js to upload a file separately as javascript is much faster than apex