Send feedback
Class Bucket (5.11.1)
Stay organized with collections
Save and categorize content based on your preferences.
Version 5.11.1 keyboard_arrow_down
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
Name
Description
storage
Storage
name
string
options
BucketOptions
Properties
acl
Property Value
getFilesStream
getFilesStream : Function ;
Property Value
Type
Description
Function
iam
Property Value
Property Value
Type
Description
Metadata
name
Property Value
signer
Property Value
Type
Description
URLSigner
storage
A reference to the Storage associated with this Bucket instance. Bucket#storage {Storage}
Property Value
userProject
A user project to apply to each request from this bucket. Bucket#userProject {string}
Property Value
Methods
addLifecycleRule(rule, options)
addLifecycleRule ( rule : LifecycleRule , options ?: AddLifecycleRuleOptions ) : Promise<SetBucketMetadataResponse> ;
Parameters
Name
Description
rule
LifecycleRule
options
AddLifecycleRuleOptions
Returns
Type
Description
Promise <SetBucketMetadataResponse >
addLifecycleRule(rule, options, callback)
addLifecycleRule ( rule : LifecycleRule , options : AddLifecycleRuleOptions , callback : SetBucketMetadataCallback ) : void ;
Parameters
Returns
addLifecycleRule(rule, callback)
addLifecycleRule ( rule : LifecycleRule , callback : SetBucketMetadataCallback ) : void ;
Parameters
Returns
combine(sources, destination, options)
combine ( sources : string [] | File [], destination : string | File , options ?: CombineOptions ) : Promise<CombineResponse> ;
Parameters
Name
Description
sources
string[] | File []
destination
string | File
options
CombineOptions
Returns
Type
Description
Promise <CombineResponse >
combine(sources, destination, options, callback)
combine ( sources : string [] | File [], destination : string | File , options : CombineOptions , callback : CombineCallback ) : void ;
Parameters
Returns
combine(sources, destination, callback)
combine ( sources : string [] | File [], destination : string | File , callback : CombineCallback ) : void ;
Parameters
Name
Description
sources
string[] | File []
destination
string | File
callback
CombineCallback
Returns
createChannel(id, config, options)
createChannel ( id : string , config : CreateChannelConfig , options ?: CreateChannelOptions ) : Promise<CreateChannelResponse> ;
Parameters
Returns
Type
Description
Promise <CreateChannelResponse >
createChannel(id, config, callback)
createChannel ( id : string , config : CreateChannelConfig , callback : CreateChannelCallback ) : void ;
Parameters
Returns
createChannel(id, config, options, callback)
createChannel ( id : string , config : CreateChannelConfig , options : CreateChannelOptions , callback : CreateChannelCallback ) : void ;
Parameters
Returns
createNotification(topic, options)
createNotification ( topic : string , options ?: CreateNotificationOptions ) : Promise<CreateNotificationResponse> ;
Parameters
Returns
Type
Description
Promise <CreateNotificationResponse >
createNotification(topic, options, callback)
createNotification ( topic : string , options : CreateNotificationOptions , callback : CreateNotificationCallback ) : void ;
Parameters
Returns
createNotification(topic, callback)
createNotification ( topic : string , callback : CreateNotificationCallback ) : void ;
Parameters
Returns
deleteFiles(query)
deleteFiles ( query ?: DeleteFilesOptions ) : Promise<void> ;
Parameter
Returns
Type
Description
Promise <void>
deleteFiles(callback)
deleteFiles ( callback : DeleteFilesCallback ) : void ;
Parameter
Returns
deleteFiles(query, callback)
deleteFiles ( query : DeleteFilesOptions , callback : DeleteFilesCallback ) : void ;
Parameters
Returns
deleteLabels(labels)
deleteLabels ( labels ?: string | string []) : Promise<DeleteLabelsResponse> ;
Parameter
Name
Description
labels
string | string[]
Returns
Type
Description
Promise <DeleteLabelsResponse >
deleteLabels(callback)
deleteLabels ( callback : DeleteLabelsCallback ) : void ;
Parameter
Name
Description
callback
DeleteLabelsCallback
Returns
deleteLabels(labels, callback)
deleteLabels ( labels : string | string [], callback : DeleteLabelsCallback ) : void ;
Parameters
Name
Description
labels
string | string[]
callback
DeleteLabelsCallback
Returns
disableRequesterPays()
disableRequesterPays () : Promise<DisableRequesterPaysResponse> ;
Returns
Type
Description
Promise <DisableRequesterPaysResponse >
disableRequesterPays(callback)
disableRequesterPays ( callback : DisableRequesterPaysCallback ) : void ;
Parameter
Returns
enableLogging(config)
enableLogging ( config : EnableLoggingOptions ) : Promise<SetBucketMetadataResponse> ;
Parameter
Name
Description
config
EnableLoggingOptions
Returns
Type
Description
Promise <SetBucketMetadataResponse >
enableLogging(config, callback)
enableLogging ( config : EnableLoggingOptions , callback : SetBucketMetadataCallback ) : void ;
Parameters
Returns
enableRequesterPays()
enableRequesterPays () : Promise<EnableRequesterPaysResponse> ;
Returns
Type
Description
Promise <EnableRequesterPaysResponse >
enableRequesterPays(callback)
enableRequesterPays ( callback : EnableRequesterPaysCallback ) : void ;
Parameter
Returns
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
Name
Description
name
string
The name of the file in this bucket.
options
FileOptions
Configuration options.
Returns
Type
Description
File
{File}
getFiles(query)
getFiles ( query ?: GetFilesOptions ) : Promise<GetFilesResponse> ;
Parameter
Returns
Type
Description
Promise <GetFilesResponse >
getFiles(query, callback)
getFiles ( query : GetFilesOptions , callback : GetFilesCallback ) : void ;
Parameters
Returns
getFiles(callback)
getFiles ( callback : GetFilesCallback ) : void ;
Parameter
Returns
getId()
Returns
getLabels(options)
getLabels ( options : GetLabelsOptions ) : Promise<GetLabelsResponse> ;
Parameter
Returns
Type
Description
Promise <GetLabelsResponse >
getLabels(callback)
getLabels ( callback : GetLabelsCallback ) : void ;
Parameter
Returns
getLabels(options, callback)
getLabels ( options : GetLabelsOptions , callback : GetLabelsCallback ) : void ;
Parameters
Returns
getNotifications(options)
getNotifications ( options ?: GetNotificationsOptions ) : Promise<GetNotificationsResponse> ;
Parameter
Returns
Type
Description
Promise <GetNotificationsResponse >
getNotifications(callback)
getNotifications ( callback : GetNotificationsCallback ) : void ;
Parameter
Returns
getNotifications(options, callback)
getNotifications ( options : GetNotificationsOptions , callback : GetNotificationsCallback ) : void ;
Parameters
Returns
getSignedUrl(cfg)
getSignedUrl ( cfg : GetBucketSignedUrlConfig ) : Promise<GetSignedUrlResponse> ;
Parameter
Returns
Type
Description
Promise <GetSignedUrlResponse >
getSignedUrl(cfg, callback)
getSignedUrl ( cfg : GetBucketSignedUrlConfig , callback : GetSignedUrlCallback ) : void ;
Parameters
Returns
lock(metageneration)
lock ( metageneration : number | string ) : Promise<BucketLockResponse> ;
Parameter
Name
Description
metageneration
number | string
Returns
Type
Description
Promise <BucketLockResponse >
lock(metageneration, callback)
lock ( metageneration : number | string , callback : BucketLockCallback ) : void ;
Parameters
Returns
makeAllFilesPublicPrivate_(options)
makeAllFilesPublicPrivate_ ( options ?: MakeAllFilesPublicPrivateOptions ) : Promise<MakeAllFilesPublicPrivateResponse> ;
Parameter
Name
Description
options
MakeAllFilesPublicPrivateOptions
Returns
Type
Description
Promise <MakeAllFilesPublicPrivateResponse >
makeAllFilesPublicPrivate_(callback)
makeAllFilesPublicPrivate_ ( callback : MakeAllFilesPublicPrivateCallback ) : void ;
Parameter
Name
Description
callback
MakeAllFilesPublicPrivateCallback
Returns
makeAllFilesPublicPrivate_(options, callback)
makeAllFilesPublicPrivate_ ( options : MakeAllFilesPublicPrivateOptions , callback : MakeAllFilesPublicPrivateCallback ) : void ;
Parameters
Name
Description
options
MakeAllFilesPublicPrivateOptions
callback
MakeAllFilesPublicPrivateCallback
Returns
makePrivate(options)
makePrivate ( options ?: MakeBucketPrivateOptions ) : Promise<MakeBucketPrivateResponse> ;
Parameter
Returns
Type
Description
Promise <MakeBucketPrivateResponse >
makePrivate(callback)
makePrivate ( callback : MakeBucketPrivateCallback ) : void ;
Parameter
Returns
makePrivate(options, callback)
makePrivate ( options : MakeBucketPrivateOptions , callback : MakeBucketPrivateCallback ) : void ;
Parameters
Returns
makePublic(options)
makePublic ( options ?: MakeBucketPublicOptions ) : Promise<MakeBucketPublicResponse> ;
Parameter
Returns
Type
Description
Promise <MakeBucketPublicResponse >
makePublic(callback)
makePublic ( callback : MakeBucketPublicCallback ) : void ;
Parameter
Returns
makePublic(options, callback)
makePublic ( options : MakeBucketPublicOptions , callback : MakeBucketPublicCallback ) : void ;
Parameters
Returns
notification(id)
notification ( id : string ) : Notification ;
Get a reference to a Cloud Pub/Sub Notification.
Parameter
Name
Description
id
string
ID of notification.
Returns
Type
Description
Notification
{Notification} Notification
removeRetentionPeriod()
removeRetentionPeriod () : Promise<SetBucketMetadataResponse> ;
Returns
Type
Description
Promise <SetBucketMetadataResponse >
removeRetentionPeriod(callback)
removeRetentionPeriod ( callback : SetBucketMetadataCallback ) : void ;
Parameter
Returns
request(reqOpts)
request ( reqOpts : DecorateRequestOptions ) : Promise <[ ResponseBody , Metadata ]>;
Parameter
Name
Description
reqOpts
DecorateRequestOptions
Returns
Type
Description
Promise <[ResponseBody , Metadata ]>
request(reqOpts, callback)
request ( reqOpts : DecorateRequestOptions , callback : BodyResponseCallback ) : void ;
Parameters
Name
Description
reqOpts
DecorateRequestOptions
callback
BodyResponseCallback
Returns
setCorsConfiguration(corsConfiguration)
setCorsConfiguration ( corsConfiguration : Cors []) : Promise<SetBucketMetadataResponse> ;
Parameter
Name
Description
corsConfiguration
Cors []
Returns
Type
Description
Promise <SetBucketMetadataResponse >
setCorsConfiguration(corsConfiguration, callback)
setCorsConfiguration ( corsConfiguration : Cors [], callback : SetBucketMetadataCallback ) : void ;
Parameters
Returns
setLabels(labels, options)
setLabels ( labels : Labels , options ?: SetLabelsOptions ) : Promise<SetLabelsResponse> ;
Parameters
Returns
Type
Description
Promise <SetLabelsResponse >
setLabels(labels, callback)
setLabels ( labels : Labels , callback : SetLabelsCallback ) : void ;
Parameters
Returns
setLabels(labels, options, callback)
setLabels ( labels : Labels , options : SetLabelsOptions , callback : SetLabelsCallback ) : void ;
Parameters
Returns
setRetentionPeriod(duration)
setRetentionPeriod ( duration : number ) : Promise<SetBucketMetadataResponse> ;
Parameter
Name
Description
duration
number
Returns
Type
Description
Promise <SetBucketMetadataResponse >
setRetentionPeriod(duration, callback)
setRetentionPeriod ( duration : number , callback : SetBucketMetadataCallback ) : void ;
Parameters
Returns
setStorageClass(storageClass, options)
setStorageClass ( storageClass : string , options ?: SetBucketStorageClassOptions ) : Promise<SetBucketMetadataResponse> ;
Parameters
Returns
Type
Description
Promise <SetBucketMetadataResponse >
setStorageClass(storageClass, callback)
setStorageClass ( storageClass : string , callback : SetBucketStorageClassCallback ) : void ;
Parameters
Returns
setStorageClass(storageClass, options, callback)
setStorageClass ( storageClass : string , options : SetBucketStorageClassOptions , callback : SetBucketStorageClassCallback ) : void ;
Parameters
Returns
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
Name
Description
userProject
string
The user project.
Returns
upload(pathString, options)
upload ( pathString : string , options ?: UploadOptions ) : Promise<UploadResponse> ;
Parameters
Returns
Type
Description
Promise <UploadResponse >
upload(pathString, options, callback)
upload ( pathString : string , options : UploadOptions , callback : UploadCallback ) : void ;
Parameters
Returns
upload(pathString, callback)
upload ( pathString : string , callback : UploadCallback ) : void ;
Parameters
Returns
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-02 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-02 UTC."],[],[]]