Package io.awspring.cloud.s3
Interface S3Operations
- All Known Implementing Classes:
S3Template
public interface S3Operations
Higher level abstraction over
S3Client
providing methods for the most common use cases. Implemented by
S3Template
.- Since:
- 3.0
- Author:
- Maciej Walkowiak, Ziemowit Stolarczyk
-
Method Summary
Modifier and TypeMethodDescriptionboolean
bucketExists
(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.default URL
createSignedPutURL
(String bucketName, String key, Duration duration) 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.listObjects
(String bucketName, String prefix) Returns some or all (up to 1,000) of the objects in a bucket.boolean
objectExists
(String bucketName, String key) Checks if an S3 object exists.<T> T
Reads a Java object from a S3 bucket.Stores a Java object in a S3 bucket.default S3Resource
upload
(String bucketName, String key, InputStream inputStream) Uploads data from an input stream to a S3 bucket.upload
(String bucketName, String key, InputStream inputStream, ObjectMetadata objectMetadata) Uploads data from an input stream to a S3 bucket.
-
Method Details
-
createBucket
Creates a bucket in S3.- Parameters:
bucketName
- - the bucket name- Returns:
- created bucket location
CreateBucketResponse.location()
-
deleteBucket
Deletes a S3 bucket.- Parameters:
bucketName
- - the bucket name
-
bucketExists
Checks if an S3 bucket exists.- Parameters:
bucketName
- - the bucket name- Returns:
- true if bucket exists; false otherwise
-
deleteObject
Deletes an object from S3 bucket.- Parameters:
bucketName
- - the bucket namekey
- - the object key
-
deleteObject
Deletes an object from S3 bucket.- Parameters:
s3Url
- - the S3 url s3://bucket/key
-
objectExists
Checks if an S3 object exists.- Parameters:
bucketName
- - the bucket namekey
- - the object key- Returns:
- true if object exists; false otherwise
-
listObjects
Returns some or all (up to 1,000) of the objects in a bucket. Does not handle pagination. If you need pagination you should useS3PathMatchingResourcePatternResolver
orS3Client
- Parameters:
bucketName
- - the bucket nameprefix
- - objects prefix- Returns:
- list of
S3Resource
-
store
Stores a Java object in a S3 bucket. UsesS3ObjectConverter
for serialization.- Parameters:
bucketName
- - the bucket namekey
- - the object keyobject
- - the Java object to serialize and store- Returns:
- created
S3Resource
.
-
read
Reads a Java object from a S3 bucket. UsesS3ObjectConverter
for deserialization.- 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
S3Resource upload(String bucketName, String key, InputStream inputStream, @Nullable ObjectMetadata objectMetadata) Uploads data from an input stream to a S3 bucket.- Parameters:
bucketName
- - the bucket namekey
- - the object keyinputStream
- - the input streamobjectMetadata
- - the object metadata- Returns:
- created
S3Resource
-
upload
Uploads data from an input stream to a S3 bucket.- Parameters:
bucketName
- - the bucket namekey
- - the object keyinputStream
- - the input stream- Returns:
- created
S3Resource
-
download
Downloads object from S3.- Parameters:
bucketName
- - the bucket namekey
- - the object key- Returns:
- downloaded object represented as
S3Resource
-
createSignedGetURL
Creates a signed URL for retrieving an object from S3.- Parameters:
bucketName
- - the bucket namekey
- - the object keyduration
- - duration that the URL will work- Returns:
- a
URL
representing the signed URL
-
createSignedPutURL
URL createSignedPutURL(String bucketName, String key, Duration duration, @Nullable ObjectMetadata metadata, @Nullable String contentType) Creates a signed URL for putting an object into S3.- Parameters:
bucketName
- - the bucket namekey
- - the object keyduration
- - duration that the URL will work- Returns:
- a
URL
representing the signed URL
-
createSignedPutURL
-