Send feedback
Class Storage (5.15.6)
Stay organized with collections
Save and categorize content based on your preferences.
Version 5.15.6keyboard_arrow_down
ACLs Cloud Storage uses access control lists (ACLs) to manage object and bucket access. ACLs are the mechanism you use to share files with other users and allow other users to access your buckets and files.
To learn more about ACLs, read this overview on Access Control .
See Cloud Storage overview See Access Control
Inheritance
Service
>
Storage
Package
@google-cloud/storage
Constructors
(constructor)(options)
constructor ( options ?: StorageOptions );
Constructs the Storage client.
Parameter
Examples
Create a client that uses Application Default Credentials (ADC)
const {Storage} = require('@google-cloud/storage ');
const storage = new Storage ();
Create a client with explicit credentials
const storage = new Storage({
projectId: 'your-project-id',
keyFilename: '/path/to/keyfile.json'
});
Properties
acl
Reference to .
Storage#acl
Property Value
acl
static acl : {
OWNER_ROLE : string ;
READER_ROLE : string ;
WRITER_ROLE : string ;
};
Property Value
Type
Description
{
OWNER_ROLE: string;
READER_ROLE: string;
WRITER_ROLE: string;
}
Bucket
static Bucket : typeof Bucket ;
Property Value
Type
Description
typeof Bucket
Channel
static Channel : typeof Channel ;
Property Value
Type
Description
typeof Channel
File
static File : typeof File ;
Property Value
Type
Description
typeof File
getBucketsStream
getBucketsStream : () = > Readable ;
Property Value
Type
Description
() => internal.Readable
getHmacKeysStream
getHmacKeysStream : () = > Readable ;
Property Value
Type
Description
() => internal.Readable
HmacKey
static HmacKey : typeof HmacKey ;
Property Value
retryOptions
retryOptions : RetryOptions ;
Property Value
Type
Description
RetryOptions
Methods
bucket(name, options)
bucket ( name : string , options ?: BucketOptions ) : Bucket ;
Get a reference to a Cloud Storage bucket.
Parameters
Name
Description
name
string
Name of the bucket.
options
BucketOptions
Configuration object.
Returns
Type
Description
Bucket
{Bucket}
Example
const {Storage} = require('@google-cloud/storage ');
const storage = new Storage ();
const albums = storage.bucket('albums');
const photos = storage.bucket('photos');
channel(id, resourceId)
channel ( id : string , resourceId : string ) : Channel ;
Reference a channel to receive notifications about changes to your bucket.
Parameters
Name
Description
id
string
The ID of the channel.
resourceId
string
The resource ID of the channel.
Returns
Type
Description
Channel
{Channel}
Example
const {Storage} = require('@google-cloud/storage ');
const storage = new Storage ();
const channel = storage.channel ('id', 'resource-id');
createBucket(name, metadata)
createBucket ( name : string , metadata ?: CreateBucketRequest ) : Promise<CreateBucketResponse> ;
Parameters
Returns
createBucket(name, callback)
createBucket ( name : string , callback : BucketCallback ) : void ;
Parameters
Returns
createBucket(name, metadata, callback)
createBucket ( name : string , metadata : CreateBucketRequest , callback : BucketCallback ) : void ;
Parameters
Returns
createBucket(name, metadata, callback)
createBucket ( name : string , metadata : CreateBucketRequest , callback : BucketCallback ) : void ;
Parameters
Returns
createHmacKey(serviceAccountEmail, options)
createHmacKey ( serviceAccountEmail : string , options ?: CreateHmacKeyOptions ) : Promise<CreateHmacKeyResponse> ;
Parameters
Returns
createHmacKey(serviceAccountEmail, callback)
createHmacKey ( serviceAccountEmail : string , callback : CreateHmacKeyCallback ) : void ;
Parameters
Returns
createHmacKey(serviceAccountEmail, options, callback)
createHmacKey ( serviceAccountEmail : string , options : CreateHmacKeyOptions , callback : CreateHmacKeyCallback ) : void ;
Parameters
Returns
getBuckets(options)
getBuckets ( options ?: GetBucketsRequest ) : Promise<GetBucketsResponse> ;
Parameter
Returns
getBuckets(options, callback)
getBuckets ( options : GetBucketsRequest , callback : GetBucketsCallback ) : void ;
Parameters
Returns
getBuckets(callback)
getBuckets ( callback : GetBucketsCallback ) : void ;
Parameter
Returns
getHmacKeys(options)
getHmacKeys ( options ?: GetHmacKeysOptions ) : Promise<GetHmacKeysResponse> ;
Retrieves a list of HMAC keys matching the criteria.
The authenticated user must have storage.hmacKeys.list permission for the project in which the key exists.
Parameter
Returns
Example
const {Storage} = require('@google-cloud/storage ');
const storage = new Storage ();
storage.getHmacKeys (function(err, hmacKeys) {
if (!err) {
// hmacKeys is an array of HmacKey objects.
}
});
//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
const callback = function(err, hmacKeys, nextQuery, apiResponse) {
if (nextQuery) {
// More results exist.
storage.getHmacKeys (nextQuery, callback);
}
// The `metadata` property is populated for you with the metadata at the
// time of fetching.
hmacKeys[0].metadata;
};
storage.getHmacKeys ({
autoPaginate: false
}, callback);
//-
// If the callback is omitted, we'll return a Promise.
//-
storage.getHmacKeys ().then(function(data) {
const hmacKeys = data[0];
});
getHmacKeys(callback)
getHmacKeys ( callback : GetHmacKeysCallback ) : void ;
Parameter
Returns
getHmacKeys(options, callback)
getHmacKeys ( options : GetHmacKeysOptions , callback : GetHmacKeysCallback ) : void ;
Parameters
Returns
getServiceAccount(options)
getServiceAccount ( options ?: GetServiceAccountOptions ) : Promise<GetServiceAccountResponse> ;
Parameter
Returns
getServiceAccount(options)
getServiceAccount ( options ?: GetServiceAccountOptions ) : Promise<GetServiceAccountResponse> ;
Parameter
Returns
getServiceAccount(options, callback)
getServiceAccount ( options : GetServiceAccountOptions , callback : GetServiceAccountCallback ) : void ;
Parameters
Returns
getServiceAccount(callback)
getServiceAccount ( callback : GetServiceAccountCallback ) : void ;
Parameter
Returns
hmacKey(accessId, options)
hmacKey ( accessId : string , options ?: HmacKeyOptions ) : HmacKey ;
Get a reference to an HmacKey object. Note: this does not fetch the HMAC key's metadata. Use HmacKey#get() to retrieve and populate the metadata.
To get a reference to an HMAC key that's not created for a service account in the same project used to instantiate the Storage client, supply the project's ID as projectId in the options argument.
Parameters
Name
Description
accessId
string
The HMAC key's access ID.
options
HmacKeyOptions
HmacKey constructor owptions.
Returns
Example
const {Storage} = require('@google-cloud/storage ');
const storage = new Storage ();
const hmacKey = storage.hmacKey ('ACCESS_ID');
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-10-30 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-10-30 UTC."],[],[]]