method

bun.S3Client.size

path: string,
options?: S3Options
): Promise<number>;

Get the size of a file in bytes, using a HEAD request.

@param path

The path to the file in the bucket

@param options

Additional S3 options to override defaults

@returns

A promise that resolves to the file size in bytes

// Get size
const bytes = await bucket.size("video.mp4");
console.log(`Size: ${bytes} bytes`);

// Check if file is large
if (await bucket.size("data.zip") > 100 * 1024 * 1024) {
  console.log("File is larger than 100MB");
}