Aws s3 javascript sdk getobject angular2 for file downloads - would like
Aws s3 javascript sdk getobject angular2 for file downloads - magnificent
View S3 File in Lightning Web Component
Amazon S3 Server is used to store Salesforce files. These stored files can be viewed later whenever is required.
This blog will explain how we can display file in iframe. Here are other blogs related to uploading and downloading files using lightning component to Amazon S3 server.
https://salesforcecodex.com/2020/01/download-files-from-s3-server-using-apex/https://salesforcecodex.com/2020/01/uploading-files-to-s3-server-using-apex/Steps to create View S3 File component in LWC
- Upload S3 SDK JS library
- Create Apex Class to get file information
- Create Lightning Web Component to view S3 File
Let us see these steps in detail
1. Upload S3 SDK for JavaScript
Download AWS SDK file from https://raw.githubusercontent.com/aws/aws-sdk-js/master/dist/aws-sdk.min.js and upload this as static resource. You can put name AWSJSSDK for this static resource.
Add http://s3.amazonaws.com in remote site setting.
2. Create Apex Class to get file information
While uploading file to S3 Server, we store uploaded file’s S3 url in separate object. Let us take that object is FileStore where S3 file detail is stored.
Create apex class to get file information from FileStore.
3. Create Lightning Web Component to view S3 File
Let us create lightning web component to view file. It can take some time to get downloadable url from s3 file so create async javascript function to get file detail.
s3.getSignedUrl will call getObject method which will retrieves objects from Amazon S3. When it will get response from s3 server it will return data.
Complete LWC Code
References:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/
-
-