Class GoogleCloudStorageOperations
java.lang.Object
io.micronaut.objectstorage.googlecloud.GoogleCloudStorageOperations
- All Implemented Interfaces:
ObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean>
@EachBean(GoogleCloudStorageConfiguration.class)
@Requires(condition=ToggeableCondition.class) @Requires(beans=GoogleCloudStorageConfiguration.class)
public class GoogleCloudStorageOperations
extends Object
implements ObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,com.google.cloud.storage.Blob,Boolean>
Google Cloud implementation of
ObjectStorageOperations
.- Since:
- 1.0
- Author:
- Pavol Gressa
-
Constructor Summary
ConstructorDescriptionGoogleCloudStorageOperations
(GoogleCloudStorageConfiguration configuration, InputStreamMapper inputStreamMapper, com.google.cloud.storage.Storage storage) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies an object stored atsourceKey
todestinationKey
, within the same object storage (bucket/container).protected com.google.cloud.storage.BlobInfo.Builder
createBlobInfoBuilder
(@NonNull UploadRequest uploadRequest) @NonNull Boolean
Deletes an object from the object storage.boolean
Checks whether an entry with the given key exists in the object storage.Lists the objects that exist in the object storage.@NonNull Optional<GoogleCloudStorageEntry>
Gets the object from object storage.@NonNull UploadResponse<com.google.cloud.storage.Blob>
upload
(@NonNull UploadRequest uploadRequest) Uploads an object to the object storage.@NonNull UploadResponse<com.google.cloud.storage.Blob>
upload
(@NonNull UploadRequest uploadRequest, @NonNull Consumer<com.google.cloud.storage.BlobInfo.Builder> uploadRequestBuilder) Uploads an object to the object storage.
-
Constructor Details
-
GoogleCloudStorageOperations
public GoogleCloudStorageOperations(@Parameter GoogleCloudStorageConfiguration configuration, InputStreamMapper inputStreamMapper, com.google.cloud.storage.Storage storage) Constructor.- Parameters:
configuration
- Google Storage ConfigurationinputStreamMapper
- Input Stream Mapperstorage
- Interface for Google Cloud Storage
-
-
Method Details
-
upload
@NonNull public @NonNull UploadResponse<com.google.cloud.storage.Blob> upload(@NonNull @NonNull UploadRequest uploadRequest) Description copied from interface:ObjectStorageOperations
Uploads an object to the object storage. If there is an existing entry, it will be updated.- Specified by:
upload
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Parameters:
uploadRequest
- the upload request- Returns:
- the upload response
-
upload
@NonNull public @NonNull UploadResponse<com.google.cloud.storage.Blob> upload(@NonNull @NonNull UploadRequest uploadRequest, @NonNull @NonNull Consumer<com.google.cloud.storage.BlobInfo.Builder> uploadRequestBuilder) Description copied from interface:ObjectStorageOperations
Uploads an object to the object storage. If there is an existing entry, it will be updated.- Specified by:
upload
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Parameters:
uploadRequest
- the upload requestuploadRequestBuilder
- Upload request builder consumer- Returns:
- the upload response
-
retrieve
Description copied from interface:ObjectStorageOperations
Gets the object from object storage.- Specified by:
retrieve
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Parameters:
key
- the object path in the format/foo/bar/file
- Returns:
- the object, or empty optional if the object does not exist
-
delete
Description copied from interface:ObjectStorageOperations
Deletes an object from the object storage.- Specified by:
delete
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Parameters:
key
- object path in the format/foo/bar/file
- Returns:
- Cloud vendor-specific delete response.
-
exists
Description copied from interface:ObjectStorageOperations
Checks whether an entry with the given key exists in the object storage.- Specified by:
exists
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Parameters:
key
- object path in the format/foo/bar/file
- Returns:
- true if the entry exists, false otherwise.
-
listObjects
Description copied from interface:ObjectStorageOperations
Lists the objects that exist in the object storage.- Specified by:
listObjects
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Returns:
- a list of keys (paths) of the existing objects, if any, or an empty list otherwise.
-
copy
Description copied from interface:ObjectStorageOperations
Copies an object stored atsourceKey
todestinationKey
, within the same object storage (bucket/container). If the destination exists, it will be overwritten.- Specified by:
copy
in interfaceObjectStorageOperations<com.google.cloud.storage.BlobInfo.Builder,
com.google.cloud.storage.Blob, Boolean> - Parameters:
sourceKey
- the key of the source objectdestinationKey
- the key of the destination object
-
createBlobInfoBuilder
@NonNull protected com.google.cloud.storage.BlobInfo.Builder createBlobInfoBuilder(@NonNull @NonNull UploadRequest uploadRequest) - Parameters:
uploadRequest
- Upload Request- Returns:
- BlobInfo Builder
-