docs/ts/runtime/storage-objects.mdx
Defines a new Object Storage bucket infrastructure resource.
new Bucket(name, cfg?): Bucket
Creates a new bucket with the given name and configuration
string
BucketPerms.constructor
impl: Bucket
attrs(name, options?): Promise<ObjectAttrs>
Returns the object's attributes. Throws an error if the object does not exist.
string
Promise<ObjectAttrs>
download(name, options?): Promise<Buffer>
Downloads an object from the bucket and returns its contents.
string
Promise<Buffer>
exists(name, options?): Promise<boolean>
Returns whether the object exists in the bucket. Throws an error on network failure.
string
Promise<boolean>
list(options): AsyncGenerator<ListEntry>
AsyncGenerator<ListEntry>
publicUrl(name): string
Returns the public URL for accessing the object with the given name. Throws an error if the bucket is not public.
string
string
ref<P>(): P
P extends BucketPerms
P
remove(name, options?): Promise<void>
Removes an object from the bucket. Throws an error on network failure.
string
Promise<void>
signedDownloadUrl(name, options?): Promise<SignedDownloadUrl>
Generate an external URL to allow downloading an object from the bucket.
Anyone with possession of the URL can download the given object without any additional auth.
string
Promise<SignedDownloadUrl>
SignedDownloader.signedDownloadUrl
signedUploadUrl(name, options?): Promise<SignedUploadUrl>
Generate an external URL to allow uploading an object to the bucket.
Anyone with possession of the URL can write to the given object name without any additional auth.
string
Promise<SignedUploadUrl>
SignedUploader.signedUploadUrl
upload(
name,
data,
options?): Promise<ObjectAttrs>;
Uploads an object to the bucket.
string
Buffer
Promise<ObjectAttrs>
static named<name>(name): Bucket
Reference an existing bucket by name.
To create a new storage bucket, use new StorageBucket(...) instead.
name extends string
StringLiteral<name>
new ObjectNotFound(msg): ObjectNotFound
string
Errornew ObjectsError(msg): ObjectsError
string
Error.constructor
new PreconditionFailed(msg): PreconditionFailed
string
abstract attrs(name, options?): Promise<ObjectAttrs>
string
Promise<ObjectAttrs>
abstract exists(name, options?): Promise<boolean>
string
Promise<boolean>
Options for retrieving the attributes of an object.
optional version?: string
The object version to retrieve attributes for. Defaults to the lastest version if unset.
If bucket versioning is not enabled, this option is ignored.
Configuration options for declaring a Bucket.
optional public?: boolean
Whether the objects in the bucket should be publicly accessible, via CDN. Defaults to false if unset.
optional versioned?: boolean
Whether to enable versioning of the objects in the bucket. Defaults to false if unset.
Options for deleting an object from a bucket.
optional version?: string
The object version to delete. Defaults to the lastest version if unset.
If bucket versioning is not enabled, this option is ignored.
abstract download(name, options?): Promise<Buffer>
string
Promise<Buffer>
Options for downloading an object from a bucket.
optional version?: string
The object version to download. Defaults to the lastest version if unset.
If bucket versioning is not enabled, this option is ignored.
Options for generating a signed download URL.
optional ttl?: number
The expiration time of the url, in seconds from signing. The maximum value is seven days. If no value is given, a default of one hour is used.
Options for checking the existence of an object.
optional version?: string
The object version to check for existence. Defaults to the lastest version if unset.
If bucket versioning is not enabled, this option is ignored.
A single entry returned when listing objects in a bucket.
etag: string
name: string
size: number
abstract list(options): AsyncGenerator<ListEntry>
AsyncGenerator<ListEntry>
Options for listing objects in a bucket.
optional limit?: number
Maximum number of objects to return. Defaults to no limit.
optional prefix?: string
Only include objects with this prefix in the listing. If unset, all objects are included.
Describes the attributes of an object stored in a bucket.
optional contentType?: string
etag: string
name: string
size: number
optional version?: string
The version of the object, if bucket versioning is enabled.
abstract publicUrl(name): string
string
string
abstract remove(name, options?): Promise<void>
string
Promise<void>
abstract signedDownloadUrl(name, options?): Promise<SignedDownloadUrl>
string
Promise<SignedDownloadUrl>
A signed URL that allows downloading an object without additional auth.
url: string
abstract signedUploadUrl(name, options?): Promise<SignedUploadUrl>
string
Promise<SignedUploadUrl>
A signed URL that allows uploading an object without additional auth.
url: string
abstract upload(
name,
data,
options?): Promise<ObjectAttrs>;
string
Buffer
Promise<ObjectAttrs>
Options for uploading an object to a bucket.
optional contentType?: string
optional preconditions?: {
notExists?: boolean;
};
optional notExists?: boolean
Options for generating a signed upload URL.
optional ttl?: number
The expiration time of the url, in seconds from signing. The maximum value is seven days. If no value is given, a default of one hour is used.
<!-- symbol-end -->type ReadWriter = Uploader & SignedUploader & Downloader & SignedDownloader & Attrser & Lister & Remover