Package net.solarnetwork.common.s3
Interface S3Client
- All Superinterfaces:
net.solarnetwork.settings.SettingSpecifierProvider
- All Known Implementing Classes:
SdkS3Client
public interface S3Client
extends net.solarnetwork.settings.SettingSpecifierProvider
API for accessing S3.
- Version:
- 2.0
- Author:
- matt
-
Method Summary
Modifier and TypeMethodDescriptiondeleteObjects(Iterable<String> keys) Delete a set of keys from S3.<P> S3ObjectgetObject(String key, net.solarnetwork.service.ProgressListener<P> progressListener, P progressContext) Get a S3 object.getObjectAsString(String key) Get the contents of a S3 object as a string.getObjectURL(String key) Get a URL for a S3 object.booleanTest if the client is fully configured.listObjects(String prefix) List all available objects matching a prefix.putObject(String key, InputStream in, S3ObjectMetadata objectMetadata, net.solarnetwork.service.ProgressListener<P> progressListener, P progressContext) Put an object onto S3.Methods inherited from interface net.solarnetwork.settings.SettingSpecifierProvider
getDisplayName, getMessageSource, getSettingSpecifiers, getSettingUid, templateSettingSpecifiers
-
Method Details
-
isConfigured
boolean isConfigured()Test if the client is fully configured.- Returns:
- true if the client is configured
-
listObjects
List all available objects matching a prefix.- Parameters:
prefix- the prefix to match- Returns:
- the matching objects, never null
- Throws:
IOException- if an IO error occurs
-
getObjectAsString
Get the contents of a S3 object as a string.The S3 object is assumed to use the
UTF-8character set.- Parameters:
key- the key of the object to get- Returns:
- the string, or null if not found
- Throws:
IOException- if an IO error occurs
-
getObjectURL
Get a URL for a S3 object.- Parameters:
key- the key- Returns:
- the URL
-
getObject
<P> S3Object getObject(String key, net.solarnetwork.service.ProgressListener<P> progressListener, P progressContext) throws IOException Get a S3 object.Note that the returned object's data may not be fetched from S3 until the
InputStreamreturned byInputStreamSource.getInputStream()is read. That means theprogressListenermight not have any progress callbacks until that time as well.- Type Parameters:
P- the progress context type- Parameters:
key- the key of the object to getprogressListener- an optional progress listenerprogressContext- an optional progress context- Returns:
- the object, or null if not found
- Throws:
IOException- if an IO error occurs
-
putObject
<P> S3ObjectReference putObject(String key, InputStream in, S3ObjectMetadata objectMetadata, net.solarnetwork.service.ProgressListener<P> progressListener, P progressContext) throws IOException Put an object onto S3.- Type Parameters:
P- the progress context type- Parameters:
key- the key of the object to putin- the object contentsobjectMetadata- the object metadataprogressListener- an optional progress listenerprogressContext- an optional progress context- Returns:
- a reference to the put object
- Throws:
IOException- if an IO error occurs
-
deleteObjects
Delete a set of keys from S3.- Parameters:
keys- the keys to delete- Returns:
- the keys that were deleted
- Throws:
IOException- if an IO error occurs
-