Downloading files from Amazon S3

Home > Amazon S3 > Example 03

Explanation

This is an example of downloading a file to Amazon S3. If the file stored in S3 does not have 'Public-Read' permissions, the credentialing process may be required, so the 'Region/Bucket/AccessKey/SecretAccessKey' information is required.

//  Set the AWSS3 method.
dx.setDownloadMode("AWSS3");
dx.setAWSS3DownloadConfig({
	type: "NON-SECRET",
	accessKeyId: "ABCD...1234",
	secretAccessKey: "ABCD...1234",
	region: "",
	bucket: "abc-bucket"
});

Objects (files) stored in the S3 bucket can be accessed with the following address scheme

https://{bucketname}.s3.{region}.amazonaws.com/{key}

Therefore, it is recommended to set the object address to the URL of the virtual file.

dx.addVirtualFile({ name: "bridge_509147.jpg", size: 509147, url: "https://abc-bucket.s3.ap-northeast-2.amazonaws.com/bridge_509147.jpg" });
dx.addVirtualFile({ name: "beach_239826.jpg", size: 239826, url: "https://abc-bucket.s3.ap-northeast-2.amazonaws.com/beach_239826.jpg" });
dx.addVirtualFile({ name: "cosmos (empty) 195779.jpg", size: 195779, url: "https://abc-bucket.s3.ap-northeast-2.amazonaws.com/cosmos+%28empty%29+195779.jpg" });

Example

Singe-file download

Multiple-files download