Package io.micronaut.objectstorage.local
Class LocalStorageOperations
java.lang.Object
io.micronaut.objectstorage.local.LocalStorageOperations
- All Implemented Interfaces:
ObjectStorageOperations<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile>
@EachBean(LocalStorageConfiguration.class)
@Requires(condition=ToggeableCondition.class) @Requires(beans=LocalStorageConfiguration.class)
@Primary
public class LocalStorageOperations
extends Object
implements ObjectStorageOperations<LocalStorageOperations.LocalStorageFile,LocalStorageOperations.LocalStorageFile,LocalStorageOperations.LocalStorageFile>
Implementation of
ObjectStorageOperations
for the local file system.
Provides simple object storage used mainly for testing and local deployments,
storing files and metadata in the file system hierarchy.- Since:
- 2.0.0
- Author:
- Álvaro Sánchez-Mariscal
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
A simple wrapper around a path. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocalStorageOperations
(LocalStorageConfiguration configuration) Deprecated, for removal: This API element is subject to removal in a future version.LocalStorageOperations
(LocalStorageConfiguration configuration, @Nullable io.micronaut.runtime.server.EmbeddedServer embeddedServer, io.micronaut.objectstorage.local.LocalPresignStore localPresignStore) Creates a new LocalStorageOperations instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Copies an object stored atsourceKey
todestinationKey
, within the same object storage (bucket/container).Deletes an object from the object storage.boolean
Checks whether an entry with the given key exists in the object storage.void
invalidatePresignedRequest
(@NonNull PresignResponse presignResponse) Explicitly invalidates a previously generated pre-signed request.Lists the objects that exist in the object storage.@NonNull PresignResponse
presign
(@NonNull PresignRequest request) Generates a pre-authorized (signed) request for the given operation.@NonNull Optional<LocalStorageEntry>
Gets the object from object storage.upload
(@NonNull UploadRequest request) Uploads an object to the object storage.upload
(@NonNull UploadRequest request, @NonNull Consumer<LocalStorageOperations.LocalStorageFile> requestConsumer) Uploads an object to the object storage.
-
Field Details
-
METADATA_DIRECTORY
- See Also:
-
-
Constructor Details
-
LocalStorageOperations
@Inject public LocalStorageOperations(@Parameter LocalStorageConfiguration configuration, @Nullable @Nullable io.micronaut.runtime.server.EmbeddedServer embeddedServer, io.micronaut.objectstorage.local.LocalPresignStore localPresignStore) Creates a new LocalStorageOperations instance.- Parameters:
configuration
- The local storage configuration.embeddedServer
- The embedded server, or null.localPresignStore
- The presigned request store.
-
LocalStorageOperations
@Deprecated(since="2.10.0", forRemoval=true) public LocalStorageOperations(@Parameter LocalStorageConfiguration configuration) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
configuration
- The local storage configuration.
-
-
Method Details
-
upload
@NonNull public @NonNull UploadResponse<LocalStorageOperations.LocalStorageFile> upload(@NonNull @NonNull UploadRequest request) 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<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Parameters:
request
- the upload request- Returns:
- the upload response
-
upload
@NonNull public @NonNull UploadResponse<LocalStorageOperations.LocalStorageFile> upload(@NonNull @NonNull UploadRequest request, @NonNull @NonNull Consumer<LocalStorageOperations.LocalStorageFile> requestConsumer) 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<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Parameters:
request
- the upload requestrequestConsumer
- 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<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Parameters:
key
- the object path in the format/foo/bar/file
- Returns:
- the object, or empty optional if the object does not exist
-
delete
@NonNull public @NonNull LocalStorageOperations.LocalStorageFile delete(@NonNull @NonNull String key) Description copied from interface:ObjectStorageOperations
Deletes an object from the object storage.- Specified by:
delete
in interfaceObjectStorageOperations<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - 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<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - 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<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Returns:
- a set 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<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Parameters:
sourceKey
- the key of the source objectdestinationKey
- the key of the destination object
-
presign
Description copied from interface:ObjectStorageOperations
Generates a pre-authorized (signed) request for the given operation.- Specified by:
presign
in interfaceObjectStorageOperations<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Parameters:
request
- the presign request parameters- Returns:
- information with the generated URL and its expiration
-
invalidatePresignedRequest
Description copied from interface:ObjectStorageOperations
Explicitly invalidates a previously generated pre-signed request.- Specified by:
invalidatePresignedRequest
in interfaceObjectStorageOperations<LocalStorageOperations.LocalStorageFile,
LocalStorageOperations.LocalStorageFile, LocalStorageOperations.LocalStorageFile> - Parameters:
presignResponse
- The response returned byObjectStorageOperations.presign(PresignRequest)
.
-
LocalStorageOperations(LocalStorageConfiguration, EmbeddedServer, LocalPresignStore)
.