method
bun.S3Client.exists
path: string,
): Promise<boolean>;
Check if a file exists in the bucket, 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 true if the file exists, false otherwise
// Check existence
if (await bucket.exists("config.json")) {
const file = bucket.file("config.json");
const config = await file.json();
}
// With error handling
try {
if (!await bucket.exists("required.txt")) {
throw new Error("Required file missing");
}
} catch (err) {
console.error("Check failed:", err);
}