There are some basic problem with your code:-
You have query inside a for loop. Check these two queries in your code:-
Group owners = [SELECT Name FROM Group WHERE Id = :uId];
ContentDocumentLink files = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :pId];
You need to take out these queries outside for loop. Else you will ...
Per your comment:
[the files] may be on the order of 100-300MB
You can't process anything close to that size in Apex. The heap limit for most asynchronous code is 12MB.
While in general Apex is poorly suited to processing file data, you can do it by querying the data. For example, to get Content Files', well, content, you can query
SELECT VersionData FROM ...
Based on comments, You can achieve it using lightning app builder:-
Go to your opportunity lightning record page
click on edit page by clicking on setup icon on right top of the screen
It will open lightning app builder where you can configure the opportunity lightning record page.
Now, click on tab component where your details , related and activity tab ...
This is how i resolved it:
EVENT_LOG__c eventLog = new EVENT_LOG__c()
eventLog.Name = 'MyEvent';
If you can upload in binary format, do so. If your source platform cannot use binary, then use base64. Base64-encoded data is approximately 33% larger, meaning longer upload times, more bandwidth used, and a lower maximum file size for non-multipart uploads.
You can insert or update blob data using a non-multipart message, but you are limited to 50 MB of ...
It seems to work if you insert the ContentDocumentLink like you described above, pointing it to the root library (ContentWorkspace):
ContentDocumentLink cdl = new ContentDocumentLink();
cdl.ContentDocumentId = doc.Id;
cdl.ShareType = 'I';
cdl.Visibility = 'AllUsers';
cdl.LinkedEntityId = ws.Id; // library (ContentWorkspace) id
Then query for the ...
You'll need to implement workarounds as of now if you need custom functionality w.r.t uploading files.
The max content limit for AuraEnabled methods as mentioned by Pranay Jaiswal is 4MB, which is also reduced when it is encoded into base64 and gives you a final size limit around 1.5 -2 MB that you'll be able to upload.
One of the workarounds would involve ...
It's ContentVersion object is what you need to update.
You can update records of this object via trigger, you will need to update the SharingPrivacy field of this object.
Update this field to N for Visible to Anyone With Record Access. This means the file is visible if the user has read access to the record
Update this field to P for Private on Records. This ...