Amazon S3 File Transfer

Provides file upload and download wrapper classes for Amazon AWS SDK (c) 2017 Sport Trades Ltd

License

License

GroupId

GroupId

com.buabook
ArtifactId

ArtifactId

amazon-s3-file-transfer
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Amazon S3 File Transfer
Provides file upload and download wrapper classes for Amazon AWS SDK (c) 2017 Sport Trades Ltd
Project URL

Project URL

http://buabook.github.io
Source Code Management

Source Code Management

https://github.com/BuaBook/amazon-s3-file-transfer.git

Download amazon-s3-file-transfer

How to add to project

<!-- https://jarcasting.com/artifacts/com.buabook/amazon-s3-file-transfer/ -->
<dependency>
    <groupId>com.buabook</groupId>
    <artifactId>amazon-s3-file-transfer</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.buabook/amazon-s3-file-transfer/
implementation 'com.buabook:amazon-s3-file-transfer:1.0.1'
// https://jarcasting.com/artifacts/com.buabook/amazon-s3-file-transfer/
implementation ("com.buabook:amazon-s3-file-transfer:1.0.1")
'com.buabook:amazon-s3-file-transfer:jar:1.0.1'
<dependency org="com.buabook" name="amazon-s3-file-transfer" rev="1.0.1">
  <artifact name="amazon-s3-file-transfer" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.buabook', module='amazon-s3-file-transfer', version='1.0.1')
)
libraryDependencies += "com.buabook" % "amazon-s3-file-transfer" % "1.0.1"
[com.buabook/amazon-s3-file-transfer "1.0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
com.google.guava : guava jar 21.0
org.slf4j : slf4j-api jar 1.7.22
com.amazonaws : aws-java-sdk-s3 jar 1.11.93

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19
org.hamcrest : java-hamcrest jar 2.0.0.0

Project Modules

There are no modules declared in this project.

Amazon S3 File Transfer Library

This library provides file upload and download wrapper classes for the AWS S3 SDK.

Maven Central Build Status Coverage Status

Uploading

We wrap a TransferManager with the following features:

  • Application environment path prefix
    • This allows multiple environments to use the same S3 bucket but data separation at the root level of the bucket between them. The environment can be specified as any String.
  • Automatic content length calculation
  • Files downloaded straight to String

Uploading can be performed in 3 ways, each allow the caller to do more configuration:

  • Using an UploadContent object - requires supplying the file content as a String along with a file name for the upload.
  • Using a file name and InputStream
  • Using your own PutObjectRequest

Modifying Uploaded File Permissions

By default the permissions of a newly uploaded file will be inherited from the parent folder or bucket. If you want to upload a file with different permissions, you can use the uploadSync method directly, supplying your own PutObjectRequest:

PutObjectRequest uploadRequest = s3FileUploader.getNewPutObjectRequest(s3Path, fileDataInputStream, fileDataLength);
// Allow everyone to read uploaded file
uploadRequest.setCannedAcl(CannedAccessControlList.PublicRead);

try {
    s3FileUploader.uploadSync(uploadRequest);
} catch (AmazonClientException | IllegalArgumentException e) {
    log.error("Failed to upload public file to Amazon. Error - " + e.getMessage(), e);
}

Required Access Permissions

In order to either upload or download files from Amazon S3, an account must be created with the following permissions:

  • Download: GetObject
  • Upload: PutObject
com.buabook

BuaBook

Versions

Version
1.0.1
1.0.0