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.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.<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
-
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
-
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
-