Package io.micronaut.objectstorage
Interface ObjectStorageOperations<I,O,D>
- Type Parameters:
I
- Cloud vendor-specific upload request class or builder.O
- Cloud vendor-specific upload response.D
- Cloud vendor-specific delete response.
- All Known Implementing Classes:
AwsS3Operations
,AzureBlobStorageOperations
,GoogleCloudStorageOperations
,LocalStorageOperations
,OracleCloudStorageOperations
public interface ObjectStorageOperations<I,O,D>
Main interface for object storage operations.
- Since:
- 1.0
- Author:
- Pavol Gressa
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Copies an object stored atsourceKey
todestinationKey
, within the same object storage (bucket/container).Deletes an object from the object storage.default boolean
Checks whether an entry with the given key exists in the object storage.Lists the objects that exist in the object storage.<E extends ObjectStorageEntry<?>>
@NonNull Optional<E>Gets the object from object storage.@NonNull UploadResponse<O>
upload
(@NonNull UploadRequest request) Uploads an object to the object storage.@NonNull UploadResponse<O>
upload
(@NonNull UploadRequest request, @NonNull Consumer<I> requestConsumer) Uploads an object to the object storage.
-
Method Details
-
upload
Uploads an object to the object storage. If there is an existing entry, it will be updated.- Parameters:
request
- the upload request- Returns:
- the upload response
- Throws:
ObjectStorageException
- if there was a failure storing the object
-
upload
@NonNull @NonNull UploadResponse<O> upload(@NonNull @NonNull UploadRequest request, @NonNull @NonNull Consumer<I> requestConsumer) Uploads an object to the object storage. If there is an existing entry, it will be updated.- Parameters:
request
- the upload requestrequestConsumer
- Upload request builder consumer- Returns:
- the upload response
- Throws:
ObjectStorageException
- if there was a failure storing the object
-
retrieve
@NonNull <E extends ObjectStorageEntry<?>> @NonNull Optional<E> retrieve(@NonNull @NonNull String key) Gets the object from object storage.- Type Parameters:
E
- an instance ofObjectStorageEntry
.- Parameters:
key
- the object path in the format/foo/bar/file
- Returns:
- the object, or empty optional if the object does not exist
- Throws:
ObjectStorageException
- if there was a failure retrieving the object
-
delete
Deletes an object from the object storage.- Parameters:
key
- object path in the format/foo/bar/file
- Returns:
- Cloud vendor-specific delete response.
- Throws:
ObjectStorageException
- if there was a failure deleting the object
-
exists
Checks whether an entry with the given key exists in the object storage.- Parameters:
key
- object path in the format/foo/bar/file
- Returns:
- true if the entry exists, false otherwise.
- Since:
- 1.1.0
-
listObjects
Lists the objects that exist in the object storage.- Returns:
- a list of keys (paths) of the existing objects, if any, or an empty list otherwise.
- Since:
- 1.1.0
-
copy
Copies an object stored atsourceKey
todestinationKey
, within the same object storage (bucket/container). If the destination exists, it will be overwritten.- Parameters:
sourceKey
- the key of the source objectdestinationKey
- the key of the destination object- Since:
- 1.1.0
-