Class Bucket (5.11.1)

Create a Bucket object to interact with a Cloud Storage bucket.

Inheritance

ServiceObject > Bucket

Package

@google-cloud/storage!

Constructors

(constructor)(storage, name, options)

constructor(storage: Storage, name: string, options?: BucketOptions);

Constructs a new instance of the Bucket class

Parameters
NameDescription
storage Storage
name string
options BucketOptions

Properties

acl

acl: Acl;
Property Value
TypeDescription
Acl

getFilesStream

getFilesStream: Function;
Property Value
TypeDescription
Function

iam

iam: Iam;
Property Value
TypeDescription
Iam

metadata

metadata: Metadata;
Property Value
TypeDescription
Metadata

name

name: string;
Property Value
TypeDescription
string

signer

signer?: URLSigner;
Property Value
TypeDescription
URLSigner

storage

storage: Storage;

A reference to the Storage associated with this Bucket instance. Bucket#storage {Storage}

Property Value
TypeDescription
Storage

userProject

userProject?: string;

A user project to apply to each request from this bucket. Bucket#userProject {string}

Property Value
TypeDescription
string

Methods

addLifecycleRule(rule, options)

addLifecycleRule(rule: LifecycleRule, options?: AddLifecycleRuleOptions): Promise<SetBucketMetadataResponse>;
Parameters
NameDescription
rule LifecycleRule
options AddLifecycleRuleOptions
Returns
TypeDescription
Promise<SetBucketMetadataResponse>

addLifecycleRule(rule, options, callback)

addLifecycleRule(rule: LifecycleRule, options: AddLifecycleRuleOptions, callback: SetBucketMetadataCallback): void;
Parameters
NameDescription
rule LifecycleRule
options AddLifecycleRuleOptions
callback SetBucketMetadataCallback
Returns
TypeDescription
void

addLifecycleRule(rule, callback)

addLifecycleRule(rule: LifecycleRule, callback: SetBucketMetadataCallback): void;
Parameters
NameDescription
rule LifecycleRule
callback SetBucketMetadataCallback
Returns
TypeDescription
void

combine(sources, destination, options)

combine(sources: string[] | File[], destination: string | File, options?: CombineOptions): Promise<CombineResponse>;
Parameters
NameDescription
sources string[] | File[]
destination string | File
options CombineOptions
Returns
TypeDescription
Promise<CombineResponse>

combine(sources, destination, options, callback)

combine(sources: string[] | File[], destination: string | File, options: CombineOptions, callback: CombineCallback): void;
Parameters
NameDescription
sources string[] | File[]
destination string | File
options CombineOptions
callback CombineCallback
Returns
TypeDescription
void

combine(sources, destination, callback)

combine(sources: string[] | File[], destination: string | File, callback: CombineCallback): void;
Parameters
NameDescription
sources string[] | File[]
destination string | File
callback CombineCallback
Returns
TypeDescription
void

createChannel(id, config, options)

createChannel(id: string, config: CreateChannelConfig, options?: CreateChannelOptions): Promise<CreateChannelResponse>;
Parameters
NameDescription
id string
config CreateChannelConfig
options CreateChannelOptions
Returns
TypeDescription
Promise<CreateChannelResponse>

createChannel(id, config, callback)

createChannel(id: string, config: CreateChannelConfig, callback: CreateChannelCallback): void;
Parameters
NameDescription
id string
config CreateChannelConfig
callback CreateChannelCallback
Returns
TypeDescription
void

createChannel(id, config, options, callback)

createChannel(id: string, config: CreateChannelConfig, options: CreateChannelOptions, callback: CreateChannelCallback): void;
Parameters
NameDescription
id string
config CreateChannelConfig
options CreateChannelOptions
callback CreateChannelCallback
Returns
TypeDescription
void

createNotification(topic, options)

createNotification(topic: string, options?: CreateNotificationOptions): Promise<CreateNotificationResponse>;
Parameters
NameDescription
topic string
options CreateNotificationOptions
Returns
TypeDescription
Promise<CreateNotificationResponse>

createNotification(topic, options, callback)

createNotification(topic: string, options: CreateNotificationOptions, callback: CreateNotificationCallback): void;
Parameters
NameDescription
topic string
options CreateNotificationOptions
callback CreateNotificationCallback
Returns
TypeDescription
void

createNotification(topic, callback)

createNotification(topic: string, callback: CreateNotificationCallback): void;
Parameters
NameDescription
topic string
callback CreateNotificationCallback
Returns
TypeDescription
void

deleteFiles(query)

deleteFiles(query?: DeleteFilesOptions): Promise<void>;
Parameter
NameDescription
query DeleteFilesOptions
Returns
TypeDescription
Promise<void>

deleteFiles(callback)

deleteFiles(callback: DeleteFilesCallback): void;
Parameter
NameDescription
callback DeleteFilesCallback
Returns
TypeDescription
void

deleteFiles(query, callback)

deleteFiles(query: DeleteFilesOptions, callback: DeleteFilesCallback): void;
Parameters
NameDescription
query DeleteFilesOptions
callback DeleteFilesCallback
Returns
TypeDescription
void

deleteLabels(labels)

deleteLabels(labels?: string | string[]): Promise<DeleteLabelsResponse>;
Parameter
NameDescription
labels string | string[]
Returns
TypeDescription
Promise<DeleteLabelsResponse>

deleteLabels(callback)

deleteLabels(callback: DeleteLabelsCallback): void;
Parameter
NameDescription
callback DeleteLabelsCallback
Returns
TypeDescription
void

deleteLabels(labels, callback)

deleteLabels(labels: string | string[], callback: DeleteLabelsCallback): void;
Parameters
NameDescription
labels string | string[]
callback DeleteLabelsCallback
Returns
TypeDescription
void

disableRequesterPays()

disableRequesterPays(): Promise<DisableRequesterPaysResponse>;
Returns
TypeDescription
Promise<DisableRequesterPaysResponse>

disableRequesterPays(callback)

disableRequesterPays(callback: DisableRequesterPaysCallback): void;
Parameter
NameDescription
callback DisableRequesterPaysCallback
Returns
TypeDescription
void

enableLogging(config)

enableLogging(config: EnableLoggingOptions): Promise<SetBucketMetadataResponse>;
Parameter
NameDescription
config EnableLoggingOptions
Returns
TypeDescription
Promise<SetBucketMetadataResponse>

enableLogging(config, callback)

enableLogging(config: EnableLoggingOptions, callback: SetBucketMetadataCallback): void;
Parameters
NameDescription
config EnableLoggingOptions
callback SetBucketMetadataCallback
Returns
TypeDescription
void

enableRequesterPays()

enableRequesterPays(): Promise<EnableRequesterPaysResponse>;
Returns
TypeDescription
Promise<EnableRequesterPaysResponse>

enableRequesterPays(callback)

enableRequesterPays(callback: EnableRequesterPaysCallback): void;
Parameter
NameDescription
callback EnableRequesterPaysCallback
Returns
TypeDescription
void

file(name, options)

file(name: string, options?: FileOptions): File;

Create a File object. See File to see how to handle the different use cases you may have.

Parameters
NameDescription
name string

The name of the file in this bucket.

options FileOptions

Configuration options.

Returns
TypeDescription
File

{File}

getFiles(query)

getFiles(query?: GetFilesOptions): Promise<GetFilesResponse>;
Parameter
NameDescription
query GetFilesOptions
Returns
TypeDescription
Promise<GetFilesResponse>

getFiles(query, callback)

getFiles(query: GetFilesOptions, callback: GetFilesCallback): void;
Parameters
NameDescription
query GetFilesOptions
callback GetFilesCallback
Returns
TypeDescription
void

getFiles(callback)

getFiles(callback: GetFilesCallback): void;
Parameter
NameDescription
callback GetFilesCallback
Returns
TypeDescription
void

getId()

getId(): string;
Returns
TypeDescription
string

getLabels(options)

getLabels(options: GetLabelsOptions): Promise<GetLabelsResponse>;
Parameter
NameDescription
options GetLabelsOptions
Returns
TypeDescription
Promise<GetLabelsResponse>

getLabels(callback)

getLabels(callback: GetLabelsCallback): void;
Parameter
NameDescription
callback GetLabelsCallback
Returns
TypeDescription
void

getLabels(options, callback)

getLabels(options: GetLabelsOptions, callback: GetLabelsCallback): void;
Parameters
NameDescription
options GetLabelsOptions
callback GetLabelsCallback
Returns
TypeDescription
void

getNotifications(options)

getNotifications(options?: GetNotificationsOptions): Promise<GetNotificationsResponse>;
Parameter
NameDescription
options GetNotificationsOptions
Returns
TypeDescription
Promise<GetNotificationsResponse>

getNotifications(callback)

getNotifications(callback: GetNotificationsCallback): void;
Parameter
NameDescription
callback GetNotificationsCallback
Returns
TypeDescription
void

getNotifications(options, callback)

getNotifications(options: GetNotificationsOptions, callback: GetNotificationsCallback): void;
Parameters
NameDescription
options GetNotificationsOptions
callback GetNotificationsCallback
Returns
TypeDescription
void

getSignedUrl(cfg)

getSignedUrl(cfg: GetBucketSignedUrlConfig): Promise<GetSignedUrlResponse>;
Parameter
NameDescription
cfg GetBucketSignedUrlConfig
Returns
TypeDescription
Promise<GetSignedUrlResponse>

getSignedUrl(cfg, callback)

getSignedUrl(cfg: GetBucketSignedUrlConfig, callback: GetSignedUrlCallback): void;
Parameters
NameDescription
cfg GetBucketSignedUrlConfig
callback GetSignedUrlCallback
Returns
TypeDescription
void

lock(metageneration)

lock(metageneration: number | string): Promise<BucketLockResponse>;
Parameter
NameDescription
metageneration number | string
Returns
TypeDescription
Promise<BucketLockResponse>

lock(metageneration, callback)

lock(metageneration: number | string, callback: BucketLockCallback): void;
Parameters
NameDescription
metageneration number | string
callback BucketLockCallback
Returns
TypeDescription
void

makeAllFilesPublicPrivate_(options)

makeAllFilesPublicPrivate_(options?: MakeAllFilesPublicPrivateOptions): Promise<MakeAllFilesPublicPrivateResponse>;
Parameter
NameDescription
options MakeAllFilesPublicPrivateOptions
Returns
TypeDescription
Promise<MakeAllFilesPublicPrivateResponse>

makeAllFilesPublicPrivate_(callback)

makeAllFilesPublicPrivate_(callback: MakeAllFilesPublicPrivateCallback): void;
Parameter
NameDescription
callback MakeAllFilesPublicPrivateCallback
Returns
TypeDescription
void

makeAllFilesPublicPrivate_(options, callback)

makeAllFilesPublicPrivate_(options: MakeAllFilesPublicPrivateOptions, callback: MakeAllFilesPublicPrivateCallback): void;
Parameters
NameDescription
options MakeAllFilesPublicPrivateOptions
callback MakeAllFilesPublicPrivateCallback
Returns
TypeDescription
void

makePrivate(options)

makePrivate(options?: MakeBucketPrivateOptions): Promise<MakeBucketPrivateResponse>;
Parameter
NameDescription
options MakeBucketPrivateOptions
Returns
TypeDescription
Promise<MakeBucketPrivateResponse>

makePrivate(callback)

makePrivate(callback: MakeBucketPrivateCallback): void;
Parameter
NameDescription
callback MakeBucketPrivateCallback
Returns
TypeDescription
void

makePrivate(options, callback)

makePrivate(options: MakeBucketPrivateOptions, callback: MakeBucketPrivateCallback): void;
Parameters
NameDescription
options MakeBucketPrivateOptions
callback MakeBucketPrivateCallback
Returns
TypeDescription
void

makePublic(options)

makePublic(options?: MakeBucketPublicOptions): Promise<MakeBucketPublicResponse>;
Parameter
NameDescription
options MakeBucketPublicOptions
Returns
TypeDescription
Promise<MakeBucketPublicResponse>

makePublic(callback)

makePublic(callback: MakeBucketPublicCallback): void;
Parameter
NameDescription
callback MakeBucketPublicCallback
Returns
TypeDescription
void

makePublic(options, callback)

makePublic(options: MakeBucketPublicOptions, callback: MakeBucketPublicCallback): void;
Parameters
NameDescription
options MakeBucketPublicOptions
callback MakeBucketPublicCallback
Returns
TypeDescription
void

notification(id)

notification(id: string): Notification;

Get a reference to a Cloud Pub/Sub Notification.

Parameter
NameDescription
id string

ID of notification.

Returns
TypeDescription
Notification

{Notification} Notification

removeRetentionPeriod()

removeRetentionPeriod(): Promise<SetBucketMetadataResponse>;
Returns
TypeDescription
Promise<SetBucketMetadataResponse>

removeRetentionPeriod(callback)

removeRetentionPeriod(callback: SetBucketMetadataCallback): void;
Parameter
NameDescription
callback SetBucketMetadataCallback
Returns
TypeDescription
void

request(reqOpts)

request(reqOpts: DecorateRequestOptions): Promise<[ResponseBody, Metadata]>;
Parameter
NameDescription
reqOpts DecorateRequestOptions
Returns
TypeDescription
Promise<[ResponseBody, Metadata]>

request(reqOpts, callback)

request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
Parameters
NameDescription
reqOpts DecorateRequestOptions
callback BodyResponseCallback
Returns
TypeDescription
void

setCorsConfiguration(corsConfiguration)

setCorsConfiguration(corsConfiguration: Cors[]): Promise<SetBucketMetadataResponse>;
Parameter
NameDescription
corsConfiguration Cors[]
Returns
TypeDescription
Promise<SetBucketMetadataResponse>

setCorsConfiguration(corsConfiguration, callback)

setCorsConfiguration(corsConfiguration: Cors[], callback: SetBucketMetadataCallback): void;
Parameters
NameDescription
corsConfiguration Cors[]
callback SetBucketMetadataCallback
Returns
TypeDescription
void

setLabels(labels, options)

setLabels(labels: Labels, options?: SetLabelsOptions): Promise<SetLabelsResponse>;
Parameters
NameDescription
labels Labels
options SetLabelsOptions
Returns
TypeDescription
Promise<SetLabelsResponse>

setLabels(labels, callback)

setLabels(labels: Labels, callback: SetLabelsCallback): void;
Parameters
NameDescription
labels Labels
callback SetLabelsCallback
Returns
TypeDescription
void

setLabels(labels, options, callback)

setLabels(labels: Labels, options: SetLabelsOptions, callback: SetLabelsCallback): void;
Parameters
NameDescription
labels Labels
options SetLabelsOptions
callback SetLabelsCallback
Returns
TypeDescription
void

setRetentionPeriod(duration)

setRetentionPeriod(duration: number): Promise<SetBucketMetadataResponse>;
Parameter
NameDescription
duration number
Returns
TypeDescription
Promise<SetBucketMetadataResponse>

setRetentionPeriod(duration, callback)

setRetentionPeriod(duration: number, callback: SetBucketMetadataCallback): void;
Parameters
NameDescription
duration number
callback SetBucketMetadataCallback
Returns
TypeDescription
void

setStorageClass(storageClass, options)

setStorageClass(storageClass: string, options?: SetBucketStorageClassOptions): Promise<SetBucketMetadataResponse>;
Parameters
NameDescription
storageClass string
options SetBucketStorageClassOptions
Returns
TypeDescription
Promise<SetBucketMetadataResponse>

setStorageClass(storageClass, callback)

setStorageClass(storageClass: string, callback: SetBucketStorageClassCallback): void;
Parameters
NameDescription
storageClass string
callback SetBucketStorageClassCallback
Returns
TypeDescription
void

setStorageClass(storageClass, options, callback)

setStorageClass(storageClass: string, options: SetBucketStorageClassOptions, callback: SetBucketStorageClassCallback): void;
Parameters
NameDescription
storageClass string
options SetBucketStorageClassOptions
callback SetBucketStorageClassCallback
Returns
TypeDescription
void

setUserProject(userProject)

setUserProject(userProject: string): void;

Set a user project to be billed for all requests made from this Bucket object and any files referenced from this Bucket object.

Parameter
NameDescription
userProject string

The user project.

Returns
TypeDescription
void

upload(pathString, options)

upload(pathString: string, options?: UploadOptions): Promise<UploadResponse>;
Parameters
NameDescription
pathString string
options UploadOptions
Returns
TypeDescription
Promise<UploadResponse>

upload(pathString, options, callback)

upload(pathString: string, options: UploadOptions, callback: UploadCallback): void;
Parameters
NameDescription
pathString string
options UploadOptions
callback UploadCallback
Returns
TypeDescription
void

upload(pathString, callback)

upload(pathString: string, callback: UploadCallback): void;
Parameters
NameDescription
pathString string
callback UploadCallback
Returns
TypeDescription
void