I got a chance to work on downloading files/documents from Amazon S3 bucket with one of project. It is easy but took some time for me to figure out all the ways to make it work as required by the customer. Hence thought to share few details on this so that it can save some time of others.
Step 1: Add AWS packages to solutions from NuGet.
I am sure most of us know how to add packages to solution, still would like to add few lines on that.
- Right click on solution and select “Manage NuGet Packages”
- Browse for AWSSDK, AWS.Extensions and AWS.SessionProvider by Amazon Web services and add them to solution.
Note:
Make sure you download correct version. For my example, I used following version:
- AWSSDK – v2.3.40
- SessionProvider – v3.1.0
- Extenstions – v1.5.26.1
If these versions are not considered, I did face some issues with Search functionality since you might same AWSSDK for both Search and S3 buckets.
Step 2: Write connector class.
This connector class is responsible to connect to S3 bucket and download the file for you. Below is the small code snippet for your reference.
Step 3: Get your controller ready to connect to above connector.
Create a controller in web application which will be responsible to call above controller and add following function.
I tried to explain things as much brief as possible from my side. Please leave comments below to improve this article and like it if it helps you save your time. There are few articles available in internet on this, but I was not getting straightforward answer that can fit with DXA application. I hope, my article will help you with straight forward answer.