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, Ziemowit Stolarczyk
-
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 TypeMethodDescriptionbooleanbucketExists(String bucketName) Checks if an S3 bucket exists.createBucket(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.voiddeleteBucket(String bucketName) Deletes a S3 bucket.voiddeleteObject(String s3Url) Deletes an object from S3 bucket.voiddeleteObject(String bucketName, String key) Deletes an object from S3 bucket.Downloads object from S3.listObjects(String bucketName, String prefix) Returns some or all (up to 1,000) of the objects in a bucket.booleanobjectExists(String bucketName, String key) Checks if an S3 object exists.<T> TReads 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, waitMethods 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:S3OperationsCreates a bucket in S3.- Specified by:
createBucketin interfaceS3Operations- Parameters:
bucketName- - the bucket name- Returns:
- created bucket location
CreateBucketResponse.location()
-
deleteBucket
Description copied from interface:S3OperationsDeletes a S3 bucket.- Specified by:
deleteBucketin interfaceS3Operations- Parameters:
bucketName- - the bucket name
-
bucketExists
Description copied from interface:S3OperationsChecks if an S3 bucket exists.- Specified by:
bucketExistsin interfaceS3Operations- Parameters:
bucketName- - the bucket name- Returns:
- true if bucket exists; false otherwise
-
deleteObject
Description copied from interface:S3OperationsDeletes an object from S3 bucket.- Specified by:
deleteObjectin interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object key
-
deleteObject
Description copied from interface:S3OperationsDeletes an object from S3 bucket.- Specified by:
deleteObjectin interfaceS3Operations- Parameters:
s3Url- - the S3 url s3://bucket/key
-
objectExists
Description copied from interface:S3OperationsChecks if an S3 object exists.- Specified by:
objectExistsin interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object key- Returns:
- true if object exists; false otherwise
-
listObjects
Description copied from interface:S3OperationsReturns some or all (up to 1,000) of the objects in a bucket. Does not handle pagination. If you need pagination you should useS3PathMatchingResourcePatternResolverorS3Client- Specified by:
listObjectsin interfaceS3Operations- Parameters:
bucketName- - the bucket nameprefix- - objects prefix- Returns:
- list of
S3Resource
-
store
Description copied from interface:S3OperationsStores a Java object in a S3 bucket. UsesS3ObjectConverterfor serialization.- Specified by:
storein interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object keyobject- - the Java object to serialize and store- Returns:
- created
S3Resource.
-
read
Description copied from interface:S3OperationsReads a Java object from a S3 bucket. UsesS3ObjectConverterfor deserialization.- Specified by:
readin 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:S3OperationsUploads data from an input stream to a S3 bucket.- Specified by:
uploadin interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object keyinputStream- - the input streamobjectMetadata- - the object metadata- Returns:
- created
S3Resource
-
download
Description copied from interface:S3OperationsDownloads object from S3.- Specified by:
downloadin interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object key- Returns:
- downloaded object represented as
S3Resource
-
createSignedGetURL
Description copied from interface:S3OperationsCreates a signed URL for retrieving an object from S3.- Specified by:
createSignedGetURLin interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object keyduration- - duration that the URL will work- Returns:
- a
URLrepresenting the signed URL
-
createSignedPutURL
public URL createSignedPutURL(String bucketName, String key, Duration duration, @Nullable ObjectMetadata metadata, @Nullable String contentType) Description copied from interface:S3OperationsCreates a signed URL for putting an object into S3.- Specified by:
createSignedPutURLin interfaceS3Operations- Parameters:
bucketName- - the bucket namekey- - the object keyduration- - duration that the URL will work- Returns:
- a
URLrepresenting the signed URL
-