Skip to content

Minima.js API


Minima.js API / @minimajs/azure-blob / AzureBlobDriver

Class: AzureBlobDriver

Azure Blob Storage driver for @minimajs/disk

Provides a web-native File API interface for Azure Blob Storage, eliminating the need to learn Azure SDK methods.

Example

typescript
import { AzureBlobDriver } from '@minimajs/azure-blob';
import { createDisk } from '@minimajs/disk';

const driver = new AzureBlobDriver({
  connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING!,
  container: 'uploads',
  publicUrl: 'https://mycdn.azureedge.net',
});

const disk = createDisk({ driver });

// Web-native API - works like browser File API
const file = new File(['content'], 'test.txt');
await disk.put(file); // Auto-generates filename
await disk.put('docs/readme.md', 'Hello Azure');

const retrieved = await disk.get('docs/readme.md');
const text = await retrieved.text(); // Standard File.text()

Implements

Constructors

Constructor

ts
new AzureBlobDriver(client, options): AzureBlobDriver;

Parameters

client

BlobServiceClient

options

AzureBlobBaseDriverOptions

Returns

AzureBlobDriver

Properties

[toStringTag]

ts
[toStringTag]: string = "AzureBlobDriver";

capabilities

ts
readonly capabilities: DriverCapabilities;

Optional capability declarations — see DriverCapabilities

Implementation of

DiskDriver.capabilities


client

ts
readonly client: BlobServiceClient;

name

ts
readonly name: "azure-blob" = "azure-blob";

Driver name (e.g., 'fs', 's3', 'azure')

Implementation of

DiskDriver.name

Methods

[custom]()

ts
custom: {
  [toStringTag]: string;
  account: string;
  container: string | undefined;
  publicUrl: string | undefined;
};

Returns

ts
{
  [toStringTag]: string;
  account: string;
  container: string | undefined;
  publicUrl: string | undefined;
}
[toStringTag]
ts
[toStringTag]: string;
account
ts
account: string;
container
ts
container: string | undefined;
publicUrl
ts
publicUrl: string | undefined;

copy()

ts
copy(from, to): Promise<void>;

Copy a file to a new location

Parameters

from

string

Source absolute URL/URI

to

string

Destination absolute URL/URI

Returns

Promise<void>

Implementation of

DiskDriver.copy


delete()

ts
delete(href): Promise<void>;

Delete file by href

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise<void>

Implementation of

DiskDriver.delete


exists()

ts
exists(href): Promise<boolean>;

Check if file exists

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise<boolean>

Implementation of

DiskDriver.exists


get()

ts
get(href): Promise<
  | [ReadableStream<Uint8Array<ArrayBufferLike>>, FileMetadata]
| null>;

Retrieve file as a ReadableStream with metadata

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise< | [ReadableStream<Uint8Array<ArrayBufferLike>>, FileMetadata] | null>

Tuple of [stream, metadata] or null if not found

Implementation of

DiskDriver.get


list()

ts
list(prefixHref, listOptions?): AsyncIterable<FileMetadata>;

List files under a prefix href.

Parameters

prefixHref

string

Absolute href prefix ending with /, or "" to list everything.

listOptions?

ListOptions

Pagination options

Returns

AsyncIterable<FileMetadata>

Implementation of

DiskDriver.list


metadata()

ts
metadata(href): Promise<
  | FileMetadata
| null>;

Get file metadata without content

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise< | FileMetadata | null>

Implementation of

DiskDriver.metadata


move()

ts
move(from, to): Promise<void>;

Move a file to a new location

Parameters

from

string

Source absolute URL/URI

to

string

Destination absolute URL/URI

Returns

Promise<void>

Implementation of

DiskDriver.move


put()

ts
put(
   href, 
   stream, 
putOptions): Promise<FileMetadata>;

Store data from a ReadableStream

Parameters

href

string

Absolute URL/URI with protocol

stream

ReadableStream<Uint8Array<ArrayBufferLike>>

ReadableStream of data to store

putOptions

PutOptions

Optional metadata and content type

Returns

Promise<FileMetadata>

FileMetadata about the stored file

Implementation of

DiskDriver.put


updateMetadata()

ts
updateMetadata(href, updates): Promise<FileMetadata>;

Parameters

href

string

updates
metadata?

Record<string, string>

type?

string

Returns

Promise<FileMetadata>


url()

ts
url(href): Promise<string>;

Generate a URL for the file

Parameters

href

string

Absolute URL/URI with protocol

Returns

Promise<string>

Implementation of

DiskDriver.url