How to Connect to ALIBABA OSS Bucket and Download the items

In one of the recent project we are setting up China Website in ALI Cloud where we need to use ALI OSS Bucket, from there we need to download the items from OSS Bucket.

Prerequisites:

It's very simple and easy if you are aware of connecting to AWS S3 Connection, but no worries you need to add the Aliyun.OSS.dll in the reference in the Project.

  • Create a Connection file where we can pass the OSSAccessKey,OSSSecretKey,OSSBucketName,OSSEndPoint (this values can be set in the Web.config so that it can be retrieved from Web.Config)

  • Create a controller where we can fetch the required data, pass it to the Model and Download the same

Here the Sample Code which Clearly Explains what the "DownloadController.cs" is doing and how it is getting connected to "AliyunOSSConnector.cs"

DownloadController.cs:

 

AliyunOSSConnector.cs:

By using above files and references we are good to start connecting to ALI OSS Bucket and start downloading required items from the bucket, if you need more info please let me know...