Skip to main content
1 of 2

How to upsert really big attachments from LWC

I have a LWC that, is retrieving the body of an attachment using apex. This is retrieved just as blob, because handling it in Apex would hit limits such as String too long os Heap Size exceeded, cause the attachment may be 50MB, so to handle it I am using atob function in my LWC JS Controller.

Reading it is working just fine, but I want to be able to edit it as well, and I am afraid of facing any limit, like heap size, with a method like this one.

@AuraEnabled
public static void upsertAttachment(Attachment att) {
    upsert att;
}

Is this even possible?

I think that basically will leave no time for the heap size limit checker to run, so nothing will be detected, but I do not want to run into that issue if I am wrong.

Is there any good alternative for this?

We are an ISV and this code will be managed, in the past we were using Visualforce and Static resource leveraging AJAX toolkit, but I think locker service will no longer allow this, and we may run into problems with the security review