Skip to content

Commit 3a3d998

Browse files
committed
Add README for S3TransferManager
1 parent b5df57e commit 3a3d998

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Overview
2+
3+
This project provides a much improved experience for S3 customers needing to easily perform uploads and downloads of
4+
objects to and from S3 by providing the S3 S3TransferManager, a high level
5+
library built on the [AWS Common Runtime S3 Client](https://github.com/awslabs/aws-crt-java).
6+
7+
## Getting Started
8+
9+
### Add a dependency for the transfer manager
10+
11+
First, you need to include the dependency in your project.
12+
13+
```xml
14+
<dependency>
15+
<groupId>software.amazon.awssdk</groupId>
16+
<artifactId>s3-transfer-manager</artifactId>
17+
<version>${awsjavasdk.version}-PREVIEW</version>
18+
</dependency>
19+
```
20+
21+
Note that you need to replace `${awsjavasdk.version}` with the latest
22+
SDK version
23+
24+
### Instantiate the transfer manager
25+
You can instantiate the transfer manager easily using the default settings
26+
27+
```java
28+
29+
S3TranfserManager tranferManager = S3TransferManager.create();
30+
31+
```
32+
33+
If you wish to configure settings, we recommend using the builder instead:
34+
```java
35+
S3TransferManager transferManager =
36+
S3TransferManager.builder()
37+
.s3ClientConfiguration(b -> b.credentialsProvider(credentialProvider)
38+
.region(Region.US_WEST_2)
39+
.targetThroughputInGbps(20.0)
40+
.minimumPartSizeInBytes(10 * MB))
41+
.build();
42+
```
43+
44+
### Download an S3 object to a file
45+
To download an object, you just need to provide the destion file path and the `GetObjectRequest` that should be used for the download.
46+
47+
```java
48+
Download download = transferManager.download(b -> b.destination(path)
49+
.getObjectRequest(r -> r.bucket("bucket")
50+
.key("key")));
51+
download.completionFuture().join();
52+
```
53+
54+
### Upload a file to S3
55+
To upload a file to S3, you just need to provide the source file path and the `PutObjectRequest` that should be used for the upload.
56+
57+
```java
58+
Upload upload = transferManager.upload(b -> b.source(path)
59+
.putObjectRequest(r -> r.bucket("bucket")
60+
.key("key")));
61+
62+
upload.completionFuture().join();
63+
64+
```

0 commit comments

Comments
 (0)