Package io.awspring.cloud.s3
Class S3Template
java.lang.Object
io.awspring.cloud.s3.S3Template
- All Implemented Interfaces:
S3Operations
Higher level abstraction over
S3Client
providing methods for the most common use cases.- Since:
- 3.0
- Author:
- Maciej Walkowiak
-
Constructor Summary
ConstructorsConstructorDescriptionS3Template
(software.amazon.awssdk.services.s3.S3Client s3Client, S3OutputStreamProvider s3OutputStreamProvider, S3ObjectConverter s3ObjectConverter, software.amazon.awssdk.services.s3.presigner.S3Presigner s3Presigner) -
Method Summary
Modifier and TypeMethodDescriptioncreateBucket
(String bucketName) Creates a bucket in S3.createSignedGetURL
(String bucketName, String key, Duration duration) Creates a signed URL for retrieving an object from S3.createSignedPutURL
(String bucketName, String key, Duration duration, ObjectMetadata metadata, String contentType) Creates a signed URL for putting an object into S3.void
deleteBucket
(String bucketName) Deletes a S3 bucket.void
deleteObject
(String s3Url) Deletes an object from S3 bucket.void
deleteObject
(String bucketName, String key) Deletes an object from S3 bucket.Downloads object from S3.<T> T
Reads a Java object from a S3 bucket.Stores a Java object in a S3 bucket.upload
(String bucketName, String key, InputStream inputStream, ObjectMetadata objectMetadata) Uploads data from an input stream to a S3 bucket.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.awspring.cloud.s3.S3Operations
createSignedPutURL, upload
-
Constructor Details
-
S3Template
public S3Template(software.amazon.awssdk.services.s3.S3Client s3Client, S3OutputStreamProvider s3OutputStreamProvider, S3ObjectConverter s3ObjectConverter, software.amazon.awssdk.services.s3.presigner.S3Presigner s3Presigner)
-
-
Method Details
-
createBucket
Description copied from interface:S3Operations
Creates a bucket in S3.- Specified by:
createBucket
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket name- Returns:
- created bucket location
CreateBucketResponse.location()
-
deleteBucket
Description copied from interface:S3Operations
Deletes a S3 bucket.- Specified by:
deleteBucket
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket name
-
deleteObject
Description copied from interface:S3Operations
Deletes an object from S3 bucket.- Specified by:
deleteObject
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket namekey
- - the object key
-
deleteObject
Description copied from interface:S3Operations
Deletes an object from S3 bucket.- Specified by:
deleteObject
in interfaceS3Operations
- Parameters:
s3Url
- - the S3 url s3://bucket/key
-
store
Description copied from interface:S3Operations
Stores a Java object in a S3 bucket. UsesS3ObjectConverter
for serialization.- Specified by:
store
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket namekey
- - the object keyobject
- - the Java object to serialize and store- Returns:
- created
S3Resource
.
-
read
Description copied from interface:S3Operations
Reads a Java object from a S3 bucket. UsesS3ObjectConverter
for deserialization.- Specified by:
read
in interfaceS3Operations
- Type Parameters:
T
- - the type of the read object- Parameters:
bucketName
- - the bucket namekey
- - the object keyclazz
- - the class of the read object- Returns:
- an object
-
upload
public S3Resource upload(String bucketName, String key, InputStream inputStream, @Nullable ObjectMetadata objectMetadata) Description copied from interface:S3Operations
Uploads data from an input stream to a S3 bucket.- Specified by:
upload
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket namekey
- - the object keyinputStream
- - the input streamobjectMetadata
- - the object metadata- Returns:
- created
S3Resource
-
download
Description copied from interface:S3Operations
Downloads object from S3.- Specified by:
download
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket namekey
- - the object key- Returns:
- downloaded object represented as
S3Resource
-
createSignedGetURL
Description copied from interface:S3Operations
Creates a signed URL for retrieving an object from S3.- Specified by:
createSignedGetURL
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket namekey
- - the object keyduration
- - duration that the URL will work- Returns:
- a
URL
representing the signed URL
-
createSignedPutURL
public URL createSignedPutURL(String bucketName, String key, Duration duration, @Nullable ObjectMetadata metadata, @Nullable String contentType) Description copied from interface:S3Operations
Creates a signed URL for putting an object into S3.- Specified by:
createSignedPutURL
in interfaceS3Operations
- Parameters:
bucketName
- - the bucket namekey
- - the object keyduration
- - duration that the URL will work- Returns:
- a
URL
representing the signed URL
-