Methods

read

Read a file from the bucket.
async read(key: string): Promise<Buffer>

Parameters

key
string
required
The key/path of the file to read

Returns

Promise<Buffer>
Promise<Buffer>
The file contents as a Buffer
Example:
const content = await client.image.read("path/to/file.txt");
console.log(content.toString('utf-8'));

write

Write a file to the bucket.
async write(key: string, data: Buffer): Promise<void>

Parameters

key
string
required
The key/path where the file should be stored
data
Buffer
required
The file contents as a Buffer
Example:
await client.image.write("path/to/file.txt", Buffer.from("Hello, World!"));

delete

Delete a file from the bucket.
async delete(key: string): Promise<void>

Parameters

key
string
required
The key/path of the file to delete
Example:
await client.image.delete("path/to/file.txt");

list

List files in the bucket with a given prefix.
async list(prefix: string): Promise<string[]>

Parameters

prefix
string
required
Filter results to keys starting with this prefix

Returns

Promise<string[]>
Promise<string[]>
Array of file keys matching the prefix
Example:
// List all files with empty prefix
const allFiles = await client.image.list("");

// List files in a specific directory
const docs = await client.image.list("documents/");

exists

Check if a file exists in the bucket.
async exists(key: string): Promise<boolean>

Parameters

key
string
required
The key/path of the file to check

Returns

Promise<boolean>
Promise<boolean>
True if the file exists, false otherwise
Example:
if (await client.image.exists("file.txt")) {
    const config = await client.image.read("file.txt");
}

Presigned URLs

Generate presigned URLs for secure file access without exposing credentials.
async getDownloadUrl(key: string, options?: Partial<PresignUrlOptions>): Promise<string>
async getUploadUrl(key: string, options?: Partial<PresignUrlOptions>): Promise<string>

Parameters

key
string
required
The key/path of the file
options
Partial<PresignUrlOptions>
default:"{mode: Mode.Read, expiry: 300}"
Configuration with mode and expiry in seconds

Returns

Promise<string>
Promise<string>
The presigned URL for the file
Example:
// Download URL (default 5 minute expiry)
const downloadUrl = await client.image.getDownloadUrl("file.txt");

// Upload URL with custom expiry (1 hour)
const uploadUrl = await client.image.getUploadUrl("file.txt", {
    mode: Mode.Write,
    expiry: 3600
});