IFileUrlAdapter: {
    getPublicUrl(
        context: IReadableContext,
        key: string,
    ): Promise<null | string>;
    getSignedDownloadUrl(
        context: IReadableContext,
        key: string,
        settings: FileAdapterSignedDownloadUrlSettings,
    ): Promise<null | string>;
    getSignedUploadUrl(
        context: IReadableContext,
        key: string,
        settings: FileAdapterSignedUploadUrlSettings,
    ): Promise<string>;
}

URL adapter contract for generating secure, temporary URLs for file access and uploads. Provides public URLs for direct access, signed URLs with expiration for download/upload operations. Abstract the URL generation logic, allowing different storage backends to implement URL strategies.

This adapter role separates concerns:

  • Storage adapters handle file data (read/write/delete)
  • URL adapters handle access control (signed URLs with expiration)

All methods operate on files via key identifier and use IReadableContext for audit logging.

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

Type declaration

  • getPublicUrl:function
    • Generates a public, permanently-accessible URL for a file. Returns null if the file does not exist or public access is not supported by the adapter.

      Parameters

      • context: IReadableContext

        Readable execution context for the operation

      • key: string

        The file identifier/path

      Returns Promise<null | string>

      The public URL or null if unavailable

  • getSignedDownloadUrl:function
    • Generates a temporary signed URL for downloading a file. The URL expires after the configured duration and becomes invalid. Returns null when the adapter verifies that the file does not exist. Some backends may return a signed URL that fails when accessed if existence checks are disabled.

      Parameters

      Returns Promise<null | string>

      The signed download URL, or null when the adapter verifies the file is unavailable

  • getSignedUploadUrl:function