It's possible to integrate Amazon S3 Simple storage service and Webviewer in Salesforce for custom file management and documents viewing. This would allow Salesforce users to upload files larger than the native limit of Salesforce.
Prerequisite:
- AWS account
- AWS credential
- salesforce account
You will also need to setup Webviewer instance following the repository at:
Custom labels are custom text values that can be accessed from Apex classes and Lightning components. It's a proper place to store the access key id and secret key of AWS.
Please add the following custom labels to ensure the project runs correctly.
- AWSAccessKeyId: Your AWS access key
- AWSSecretKey: Your AWS secret key
- S3BucketName: the name of your bucket.
- S3Region: Your s3 bucket region
- targetFolderPrefix (optional): This label indicate the path that the file will be uploaded to.
By default, actions of uploading/deleting/getting files are blocked by s3 bucket. You will need to allow "GET", "POST", and "DELETE" methods in the bucket's CORS policy,
- Clone the repository at: https://github.com/PDFTron/salesforce-s3-integration
- Upload the aws-sdk.min.js file in the root folder to your Salesforce's static resources.
- Deploy the force-app to your salesforce website.
- Click the setting button on the right, and click "Edit Page".
- Drag the "S3 Files List" component from the "custom" section to the page.
- Click the "Save" button and you should be able to see the file list component on the page.
- The Files List component make a reqeust whenever listing all the folders and files at the each file path (such as /bucket/folder), as well as adding or deleting the files in the bucket. It would make quite an amount of requests when taking actions, so please make sure you have a adaquate pla