IReadableFile: {
    key: IKey;
    exists(): Promise<boolean>;
    getArrayBuffer(): Promise<null | ArrayBuffer>;
    getArrayBufferOrFail(): Promise<ArrayBuffer>;
    getBuffer(): Promise<null | Buffer<ArrayBufferLike>>;
    getBufferOrFail(): Promise<Buffer<ArrayBufferLike>>;
    getBytes(): Promise<null | Uint8Array<ArrayBufferLike>>;
    getBytesOrFail(): Promise<Uint8Array<ArrayBufferLike>>;
    getMetadata(): Promise<null | FileMetadata>;
    getMetadataOrFail(): Promise<FileMetadata>;
    getPublicUrl(): Promise<null | string>;
    getPublicUrlOrFail(): Promise<string>;
    getReadable(): Promise<null | Readable>;
    getReadableOrFail(): Promise<Readable>;
    getReadableStream(): Promise<
        null
        | ReadableStream<Uint8Array<ArrayBufferLike>>,
    >;
    getReadableStreamOrFail(): Promise<
        ReadableStream<Uint8Array<ArrayBufferLike>>,
    >;
    getSignedDownloadUrl(
        options?: FileDownloadUrlOptions,
    ): Promise<null | string>;
    getSignedDownloadUrlOrFail(
        options?: FileDownloadUrlOptions,
    ): Promise<string>;
    getText(): Promise<null | string>;
    getTextOrFail(): Promise<string>;
    missing(): Promise<boolean>;
}

Read-only interface for accessing file content and metadata. Provides multiple data format options (text, bytes, streams) and metadata retrieval. All methods follow a pattern of returning null for missing files or throwing errors on OrFail variants.

IMPORT_PATH: "@daiso-tech/core/file-storage/contracts"

Type declaration

  • Readonlykey: IKey

    The unique identifier/path for this file in storage.

  • exists:function
  • getArrayBuffer:function
    • Retrieves file content as an ArrayBuffer (standard JavaScript).

      Returns Promise<null | ArrayBuffer>

      The file content as ArrayBuffer, or null if not found

  • getArrayBufferOrFail:function
    • Retrieves file content as an ArrayBuffer (standard JavaScript).

      Returns Promise<ArrayBuffer>

      The file content as ArrayBuffer

      If the file is not found

  • getBuffer:function
    • Retrieves file content as a Node.js Buffer.

      Returns Promise<null | Buffer<ArrayBufferLike>>

      The file content as buffer, or null if not found

  • getBufferOrFail:function
    • Retrieves file content as a Node.js Buffer.

      Returns Promise<Buffer<ArrayBufferLike>>

      The file content as buffer

      If the file is not found

  • getBytes:function
    • Retrieves file content as a Uint8Array (binary data).

      Returns Promise<null | Uint8Array<ArrayBufferLike>>

      The file content as bytes, or null if not found

  • getBytesOrFail:function
    • Retrieves file content as a Uint8Array (binary data).

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The file content as bytes

      If the file is not found

  • getMetadata:function
  • getMetadataOrFail:function
  • getPublicUrl:function
    • Gets the publicly accessible URL for this file. Only works if the file storage backend supports public file access.

      Returns Promise<null | string>

      The public URL, or null if the file is not found or not publicly accessible

  • getPublicUrlOrFail:function
    • Gets the publicly accessible URL for this file. Only works if the file storage backend supports public file access.

      Returns Promise<string>

      The public URL

      If the file is not found or not publicly accessible

  • getReadable:function
    • Retrieves file content as a Node.js Readable stream. Suitable for streaming large files without loading entire content into memory.

      Returns Promise<null | Readable>

      A readable stream, or null if not found

  • getReadableOrFail:function
    • Retrieves file content as a Node.js Readable stream. Suitable for streaming large files without loading entire content into memory.

      Returns Promise<Readable>

      A readable stream

      If the file is not found

  • getReadableStream:function
    • Retrieves file content as a standard Web Streams API ReadableStream. Suitable for streaming large files without loading entire content into memory.

      Returns Promise<null | ReadableStream<Uint8Array<ArrayBufferLike>>>

      A readable stream, or null if not found

  • getReadableStreamOrFail:function
    • Retrieves file content as a standard Web Streams API ReadableStream. Suitable for streaming large files without loading entire content into memory.

      Returns Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

      A readable stream

      If the file is not found

  • getSignedDownloadUrl:function
    • Generates a signed download URL with optional constraints. The URL will be valid only for the specified TTL and can include content-type/disposition overrides.

      Parameters

      • Optionaloptions: FileDownloadUrlOptions

        Download URL configuration options (TTL, content-type, content-disposition)

      Returns Promise<null | string>

      A signed URL, or null if the file is not found

  • getSignedDownloadUrlOrFail:function
    • Generates a signed download URL with optional constraints. The URL will be valid only for the specified TTL and can include content-type/disposition overrides.

      Parameters

      • Optionaloptions: FileDownloadUrlOptions

        Download URL configuration options (TTL, content-type, content-disposition)

      Returns Promise<string>

      A signed URL

      If the file is not found

  • getText:function
  • getTextOrFail:function
  • missing:function