0

We are Salesforce Files users. We use the ContentDocuments object and create multiple ContentVersions per ContentDocument. I have been implementing a new tool to upload files and I evaluated 2 possible implementations available in Salesforce, but none of them fit all the requirements for my project which are: 1-Upload files between 1MB -100MB, 2-Create versions if a ContentDocument already exist in the record.

Implementation 1: Using "lightning-input type=file" with some apex and LWC allows me to upload new files and also update versions if needed. Downside: we are unable to upload files bigger than 5MB, seems like a very hard limit could not find workarounds for this.

Implementation 2: Using "lightning-file-upload" we are able to upload up to 2GB files. Downside We are unable to insert new versions in case of the file already exist in the container.

Question: Do you guys know a way to make 'lightning-file-upload' to work with versions?? example: user A is uploading an "ID file" to a custom object, if a file with the same name already exists, just create a new ContentVersion of the existing ContentDocument.

My plan: Before invoking the REST API from LWC to upload a file, I was planning in create an after insert trigger to complement "lightning-file-upload", basically run something in the backend to find matching files and create new versions if needed when the user uploads a file.... it won't be pretty.

Thanks!

3
  • The trigger is the way to go. you can add custom fields to Content_version and pass data along with lightning-file-upload and can then use those values in your Apex code to assign it to the correct file.
    – zaitsman
    Commented May 13, 2021 at 0:18
  • Thanks @zaitsman. That's what I did and it's working Commented May 13, 2021 at 13:26
  • @AlexCortes could you please post your answer to this ? We are currently running into the same problem
    – olirwin
    Commented Apr 7, 2022 at 14:13

0

You must log in to answer this question.