Fake Mirrors
    Preparing search index...

    Class MinioStorage

    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 { STORAGE, Storage, MinioStorage } from '@famir/storage'

    // Get container singleton
    const container = DIContainer.getInstance()

    // Register dependency in container
    MinioStorage.register(container)

    // Resolve dependency from container
    const storage = container.resolve<Storage>(STORAGE)

    // Checking the existence of the bucket
    await storage.ensureBucketExists()

    // Store object in storage
    await storage.putObject('test.txt', Buffer.from('Hello'), {
    'Content-Type': 'text/plain'
    })

    // Retrieve object from storage
    const data = await storage.getObject('test.txt')
    console.log(data.toString()) // 'Hello'

    // Delete object from storage
    await storage.deleteObject('test.txt')

    Implements

    • Ensures that the configured bucket exists.

      This method is typically called during application startup to verify that the storage bucket is accessible. If the bucket does not exist, a bootstrap error is thrown.

      Returns Promise<void>

      BootstrapError If the bucket does not exist or is inaccessible.

    • Retrieves an object from the storage.

      Parameters

      • objectName: string

        The path of the object to retrieve.

      Returns Promise<Buffer<ArrayBufferLike>>

      The object content as a Buffer.

      StorageError If the object cannot be retrieved.

    • Stores an object in the storage.

      Parameters

      • objectName: string

        The path to assign to the object.

      • data: Buffer

        The object content as a Buffer.

      • headers: Record<string, string>

        Custom headers to attach to the object.

      Returns Promise<void>

      StorageError If the object cannot be stored.