MinIO-based storage implementation.
Uses the official MinIO JavaScript client to interact with MinIO or any S3-compatible storage service.
Depends:
import { DIContainer } from '@famir/common'import { MinioStorage } from '@famir/storage'// Get container singletonconst container = DIContainer.getInstance()// Register dependency in containerMinioStorage.register(container) Copy
import { DIContainer } from '@famir/common'import { MinioStorage } from '@famir/storage'// Get container singletonconst container = DIContainer.getInstance()// Register dependency in containerMinioStorage.register(container)
import { DIContainer } from '@famir/common'import { STORAGE, Storage } from '@famir/domain'// Get container singletonconst container = DIContainer.getInstance()// Resolve dependency from containerconst storage = container.resolve<Storage>(STORAGE)// Checking the existence of the bucketawait storage.ensureBucketExists()// Store object in storageawait storage.putObject('test.txt', Buffer.from('Hello'), { 'Content-Type': 'text/plain'})// Retrieve object from storageconst data = await storage.getObject('test.txt')console.log(data.toString()) // 'Hello'// Delete object from storageawait storage.deleteObject('test.txt') Copy
import { DIContainer } from '@famir/common'import { STORAGE, Storage } from '@famir/domain'// Get container singletonconst container = DIContainer.getInstance()// Resolve dependency from containerconst storage = container.resolve<Storage>(STORAGE)// Checking the existence of the bucketawait storage.ensureBucketExists()// Store object in storageawait storage.putObject('test.txt', Buffer.from('Hello'), { 'Content-Type': 'text/plain'})// Retrieve object from storageconst data = await storage.getObject('test.txt')console.log(data.toString()) // 'Hello'// Delete object from storageawait storage.deleteObject('test.txt')
Creates a new storage instance.
The validator instance.
The config instance.
The logger instance.
Checks that the configured bucket exists.
This method is typically called during application startup to verify that the storage bucket is accessible.
LifecycleError If the bucket does not exist or is inaccessible.
Deletes an object from the storage.
The path of the object to delete.
StorageError If the object cannot be deleted.
Retrieves an object from the storage.
The path of the object to retrieve.
The object content as a Buffer.
StorageError If the object cannot be retrieved.
Stores an object in the storage.
The path to assign to the object.
Custom headers to attach to the object.
StorageError If the object cannot be stored.
Static
Registers the storage as a singleton in the DI container.
The DI container to register in.
MinIO-based storage implementation.
Uses the official MinIO JavaScript client to interact with MinIO or any S3-compatible storage service.
See
Depends:
Example
Example