@google-cloud/storage
- Version 5.19.4
- Published
- 761 kB
- 25 dependencies
- Apache-2.0 license
Install
npm i @google-cloud/storage
yarn add @google-cloud/storage
pnpm add @google-cloud/storage
Overview
Cloud Storage Client Library for Node.js
Index
Classes
Bucket
- acl
- addLifecycleRule()
- combine()
- createChannel()
- createNotification()
- deleteFiles()
- deleteLabels()
- disableAutoRetryConditionallyIdempotent_()
- disableRequesterPays()
- enableLogging()
- enableRequesterPays()
- file()
- getFiles()
- getFilesStream()
- getId()
- getLabels()
- getNotifications()
- getSignedUrl()
- iam
- instancePreconditionOpts
- lock()
- makeAllFilesPublicPrivate_()
- makePrivate()
- makePublic()
- metadata
- name
- notification()
- removeRetentionPeriod()
- request()
- setCorsConfiguration()
- setLabels()
- setRetentionPeriod()
- setStorageClass()
- setUserProject()
- signer
- storage
- upload()
- userProject
File
- acl
- bucket
- copy()
- createReadStream()
- createResumableUpload()
- createWriteStream()
- deleteResumableCache()
- disableAutoRetryConditionallyIdempotent_()
- download()
- generateSignedPostPolicyV2()
- generateSignedPostPolicyV4()
- generation
- getExpirationDate()
- getSignedPolicy()
- getSignedUrl()
- instancePreconditionOpts
- isPublic()
- kmsKeyName
- makePrivate()
- makePublic()
- metadata
- move()
- name
- parent
- publicUrl()
- rename()
- request()
- rotateEncryptionKey()
- save()
- setEncryptionKey()
- setStorageClass()
- setUserProject()
- signer
- startResumableUpload_()
- startSimpleUpload_()
- storage
- userProject
Interfaces
Enums
Type Aliases
- AddAclResponse
- BucketExistsCallback
- BucketExistsResponse
- BucketLockResponse
- CombineResponse
- CopyResponse
- CreateBucketResponse
- CreateChannelResponse
- CreateHmacKeyResponse
- CreateNotificationResponse
- CreateResumableUploadResponse
- DeleteBucketResponse
- DeleteFileResponse
- DeleteLabelsCallback
- DeleteLabelsResponse
- DisableRequesterPaysResponse
- DownloadCallback
- DownloadResponse
- EnableRequesterPaysResponse
- FileExistsResponse
- GenerateSignedPostPolicyV2Callback
- GenerateSignedPostPolicyV2Options
- GenerateSignedPostPolicyV2Response
- GenerateSignedPostPolicyV4Response
- GetAclResponse
- GetBucketMetadataResponse
- GetBucketResponse
- GetBucketsResponse
- GetExpirationDateResponse
- GetFileMetadataResponse
- GetFileResponse
- GetFilesResponse
- GetHmacKeysResponse
- GetLabelsResponse
- GetNotificationMetadataResponse
- GetNotificationResponse
- GetNotificationsResponse
- GetPolicyResponse
- GetServiceAccountResponse
- GetSignedPolicyResponse
- GetSignedUrlResponse
- HmacKeyMetadataResponse
- MakeBucketPrivateResponse
- MakeBucketPublicResponse
- MakeFilePrivateCallback
- MakeFilePrivateResponse
- MakeFilePublicResponse
- MoveResponse
- PredefinedAcl
- RemoveAclResponse
- RotateEncryptionKeyCallback
- RotateEncryptionKeyOptions
- RotateEncryptionKeyResponse
- SetBucketMetadataResponse
- SetFileMetadataResponse
- SetLabelsResponse
- SetPolicyResponse
- SetStorageClassResponse
- TestIamPermissionsResponse
- UpdateAclResponse
- UploadResponse
Classes
class Bucket
class Bucket extends ServiceObject {}
Create a Bucket object to interact with a Cloud Storage bucket.
Parameter storage
A Storage instance.
Parameter name
The name of the bucket.
Parameter options
Configuration object.
Parameter
{string} [options.userProject] User project.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('albums');
constructor
constructor(storage: Storage, name: string, options?: BucketOptions);
property acl
acl: Acl;
property iam
iam: Iam;
property instancePreconditionOpts
instancePreconditionOpts?: PreconditionOptions;
property metadata
metadata: any;
property name
name: string;
property signer
signer?: URLSigner;
property storage
storage: Storage;
property userProject
userProject?: string;
A user project to apply to each request from this bucket. Bucket#userProject {string}
method addLifecycleRule
addLifecycleRule: { ( rule: LifecycleRule, options?: AddLifecycleRuleOptions ): Promise<SetBucketMetadataResponse>; ( rule: LifecycleRule, options: AddLifecycleRuleOptions, callback: SetBucketMetadataCallback ): void; (rule: LifecycleRule, callback: SetBucketMetadataCallback): void;};
method combine
combine: { ( sources: string[] | File[], destination: string | File, options?: CombineOptions ): Promise<CombineResponse>; ( sources: string[] | File[], destination: string | File, options: CombineOptions, callback: CombineCallback ): void; ( sources: string[] | File[], destination: string | File, callback: CombineCallback ): void;};
method createChannel
createChannel: { ( id: string, config: CreateChannelConfig, options?: CreateChannelOptions ): Promise<CreateChannelResponse>; ( id: string, config: CreateChannelConfig, callback: CreateChannelCallback ): void; ( id: string, config: CreateChannelConfig, options: CreateChannelOptions, callback: CreateChannelCallback ): void;};
method createNotification
createNotification: { ( topic: string, options?: CreateNotificationOptions ): Promise<CreateNotificationResponse>; ( topic: string, options: CreateNotificationOptions, callback: CreateNotificationCallback ): void; (topic: string, callback: CreateNotificationCallback): void;};
method deleteFiles
deleteFiles: { (query?: DeleteFilesOptions): Promise<void>; (callback: DeleteFilesCallback): void; (query: DeleteFilesOptions, callback: DeleteFilesCallback): void;};
method deleteLabels
deleteLabels: { (labels?: string | string[]): Promise<DeleteLabelsResponse>; (callback: SetLabelsCallback): void; (labels: string | string[], callback: SetLabelsCallback): void;};
method disableAutoRetryConditionallyIdempotent_
disableAutoRetryConditionallyIdempotent_: ( coreOpts: any, methodType: AvailableServiceObjectMethods) => void;
method disableRequesterPays
disableRequesterPays: { (): Promise<DisableRequesterPaysResponse>; (callback: DisableRequesterPaysCallback): void;};
method enableLogging
enableLogging: { (config: EnableLoggingOptions): Promise<SetBucketMetadataResponse>; (config: EnableLoggingOptions, callback: SetBucketMetadataCallback): void;};
method enableRequesterPays
enableRequesterPays: { (): Promise<EnableRequesterPaysResponse>; (callback: EnableRequesterPaysCallback): void;};
method file
file: (name: string, options?: FileOptions) => File;
Create a File object. See File to see how to handle the different use cases you may have.
Parameter name
The name of the file in this bucket.
Parameter options
Configuration options.
Parameter
{string|number} [options.generation] Only use a specific revision of this file.
Parameter
{string} [options.encryptionKey] A custom encryption key. See Customer-supplied Encryption Keys.
Parameter
{string} [options.kmsKeyName] The name of the Cloud KMS key that will be used to encrypt the object. Must be in the format:
projects/my-project/locations/location/keyRings/my-kr/cryptoKeys/my-key
. KMS key ring must use the same location as the bucket.Parameter
{string} [options.userProject] The ID of the project which will be billed for all requests made from File object.
Returns
{File}
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('albums');const file = bucket.file('my-existing-file.png');
method getFiles
getFiles: { (query?: GetFilesOptions): Promise<GetFilesResponse>; (query: GetFilesOptions, callback: GetFilesCallback): void; (callback: GetFilesCallback): void;};
method getFilesStream
getFilesStream: (query?: GetFilesOptions) => Readable;
method getId
getId: () => string;
method getLabels
getLabels: { (options?: GetLabelsOptions): Promise<GetLabelsResponse>; (callback: GetLabelsCallback): void; (options: GetLabelsOptions, callback: GetLabelsCallback): void;};
method getNotifications
getNotifications: { (options?: GetNotificationsOptions): Promise<GetNotificationsResponse>; (callback: GetNotificationsCallback): void; (options: GetNotificationsOptions, callback: GetNotificationsCallback): void;};
method getSignedUrl
getSignedUrl: { (cfg: GetBucketSignedUrlConfig): Promise<GetSignedUrlResponse>; (cfg: GetBucketSignedUrlConfig, callback: GetSignedUrlCallback): void;};
method lock
lock: { (metageneration: number | string): Promise<BucketLockResponse>; (metageneration: string | number, callback: BucketLockCallback): void;};
method makeAllFilesPublicPrivate_
makeAllFilesPublicPrivate_: { ( options?: MakeAllFilesPublicPrivateOptions ): Promise<MakeAllFilesPublicPrivateResponse>; (callback: MakeAllFilesPublicPrivateCallback): void; ( options: MakeAllFilesPublicPrivateOptions, callback: MakeAllFilesPublicPrivateCallback ): void;};
method makePrivate
makePrivate: { (options?: MakeBucketPrivateOptions): Promise<MakeBucketPrivateResponse>; (callback: MakeBucketPrivateCallback): void; ( options: MakeBucketPrivateOptions, callback: MakeBucketPrivateCallback ): void;};
method makePublic
makePublic: { (options?: MakeBucketPublicOptions): Promise<MakeBucketPublicResponse>; (callback: MakeBucketPublicCallback): void; (options: MakeBucketPublicOptions, callback: MakeBucketPublicCallback): void;};
method notification
notification: (id: string) => Notification;
Get a reference to a Cloud Pub/Sub Notification.
Parameter id
ID of notification.
Returns
{Notification}
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('my-bucket');const notification = bucket.notification('1');See Also
Notification
method removeRetentionPeriod
removeRetentionPeriod: { (): Promise<SetBucketMetadataResponse>; (callback: SetBucketMetadataCallback): void;};
method request
request: { (reqOpts: DecorateRequestOptions): Promise<[ResponseBody, Metadata]>; (reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;};
method setCorsConfiguration
setCorsConfiguration: { (corsConfiguration: Cors[]): Promise<SetBucketMetadataResponse>; (corsConfiguration: Cors[], callback: SetBucketMetadataCallback): void;};
method setLabels
setLabels: { (labels: Labels, options?: SetLabelsOptions): Promise<SetLabelsResponse>; (labels: Labels, callback: SetLabelsCallback): void; ( labels: Labels, options: SetLabelsOptions, callback: SetLabelsCallback ): void;};
method setRetentionPeriod
setRetentionPeriod: { (duration: number): Promise<SetBucketMetadataResponse>; (duration: number, callback: SetBucketMetadataCallback): void;};
method setStorageClass
setStorageClass: { ( storageClass: string, options?: SetBucketStorageClassOptions ): Promise<SetBucketMetadataResponse>; (storageClass: string, callback: SetBucketStorageClassCallback): void; ( storageClass: string, options: SetBucketStorageClassOptions, callback: SetBucketStorageClassCallback ): void;};
method setUserProject
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 userProject
The user project.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('albums');bucket.setUserProject('grape-spaceship-123');
method upload
upload: { (pathString: string, options?: UploadOptions): Promise<UploadResponse>; (pathString: string, options: UploadOptions, callback: UploadCallback): void; (pathString: string, callback: UploadCallback): void;};
class Channel
class Channel extends ServiceObject {}
Create a channel object to interact with a Cloud Storage channel.
Parameter id
The ID of the channel.
Parameter resourceId
The resource ID of the channel.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const channel = storage.channel('id', 'resource-id');
constructor
constructor(storage: Storage, id: string, resourceId: string);
method stop
stop: { (): Promise<Metadata>; (callback: StopCallback): void };
class File
class File extends ServiceObject<File> {}
A File object is created from your Bucket object using Bucket#file.
constructor
constructor(bucket: Bucket, name: string, options?: FileOptions);
Constructs a file object.
Parameter bucket
The Bucket instance this file is attached to.
Parameter name
The name of the remote file.
Parameter options
Configuration options.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const myBucket = storage.bucket('my-bucket');const file = myBucket.file('my-file');
property acl
acl: Acl;
property bucket
bucket: Bucket;
property generation
generation?: number;
property instancePreconditionOpts
instancePreconditionOpts?: PreconditionOptions;
property kmsKeyName
kmsKeyName?: string;
property metadata
metadata: any;
property name
name: string;
property parent
parent: Bucket;
property signer
signer?: URLSigner;
property storage
storage: Storage;
property userProject
userProject?: string;
method copy
copy: { ( destination: string | Bucket | File, options?: CopyOptions ): Promise<CopyResponse>; (destination: string | File | Bucket, callback: CopyCallback): void; ( destination: string | File | Bucket, options: CopyOptions, callback: CopyCallback ): void;};
method createReadStream
createReadStream: (options?: CreateReadStreamOptions) => Readable;
Create a readable stream to read the contents of the remote file. It can be piped to a writable stream or listened to for 'data' events to read a file's contents.
In the unlikely event there is a mismatch between what you downloaded and the version in your Bucket, your error handler will receive an error with code "CONTENT_DOWNLOAD_MISMATCH". If you receive this error, the best recourse is to try downloading the file again.
For faster crc32c computation, you must manually install `fast-crc32c`:
$ npm install --save fast-crc32c
NOTE: Readable streams will emit the
end
event when the file is fully downloaded.Parameter options
Configuration options.
Returns
{ReadableStream}
Example 1
//-// <h4>Downloading a File</h4>//// The example below demonstrates how we can reference a remote file, then// pipe its contents to a local file. This is effectively creating a local// backup of your remote data.//-const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('my-bucket');const fs = require('fs');const remoteFile = bucket.file('image.png');const localFilename = '/Users/stephen/Photos/image.png';remoteFile.createReadStream().on('error', function(err) {}).on('response', function(response) {// Server connected and responded with the specified status and headers.}).on('end', function() {// The file is fully downloaded.}).pipe(fs.createWriteStream(localFilename));//-// To limit the downloaded data to only a byte range, pass an options// object.//-const logFile = myBucket.file('access_log');logFile.createReadStream({start: 10000,end: 20000}).on('error', function(err) {}).pipe(fs.createWriteStream('/Users/stephen/logfile.txt'));//-// To read a tail byte range, specify only `options.end` as a negative// number.//-const logFile = myBucket.file('access_log');logFile.createReadStream({end: -100}).on('error', function(err) {}).pipe(fs.createWriteStream('/Users/stephen/logfile.txt'));
method createResumableUpload
createResumableUpload: { ( options?: CreateResumableUploadOptions ): Promise<CreateResumableUploadResponse>; ( options: CreateResumableUploadOptions, callback: CreateResumableUploadCallback ): void; (callback: CreateResumableUploadCallback): void;};
method createWriteStream
createWriteStream: (options?: CreateWriteStreamOptions) => Writable;
Create a writable stream to overwrite the contents of the file in your bucket.
A File object can also be used to create files for the first time.
Resumable uploads are automatically enabled and must be shut off explicitly by setting
options.resumable
tofalse
.Resumable uploads require write access to the $HOME directory. Through `config-store`, some metadata is stored. By default, if the directory is not writable, we will fall back to a simple upload. However, if you explicitly request a resumable upload, and we cannot write to the config directory, we will return a
ResumableUploadError
.There is some overhead when using a resumable upload that can cause noticeable performance degradation while uploading a series of small files. When uploading files less than 10MB, it is recommended that the resumable feature is disabled.
For faster crc32c computation, you must manually install `fast-crc32c`:
$ npm install --save fast-crc32c
NOTE: Writable streams will emit the
finish
event when the file is fully uploaded.See Upload Options (Simple or Resumable) See Objects: insert API Documentation
Parameter options
Configuration options.
Returns
{WritableStream}
Example 1
const fs = require('fs');const {Storage} = require('@google-cloud/storage');const storage = new Storage();const myBucket = storage.bucket('my-bucket');const file = myBucket.file('my-file');//-// <h4>Uploading a File</h4>//// Now, consider a case where we want to upload a file to your bucket. You// have the option of using {@link Bucket#upload}, but that is just// a convenience method which will do the following.//-fs.createReadStream('/Users/stephen/Photos/birthday-at-the-zoo/panda.jpg').pipe(file.createWriteStream()).on('error', function(err) {}).on('finish', function() {// The file upload is complete.});//-// <h4>Uploading a File with gzip compression</h4>//-fs.createReadStream('/Users/stephen/site/index.html').pipe(file.createWriteStream({ gzip: true })).on('error', function(err) {}).on('finish', function() {// The file upload is complete.});//-// Downloading the file with `createReadStream` will automatically decode// the file.//-//-// <h4>Uploading a File with Metadata</h4>//// One last case you may run into is when you want to upload a file to your// bucket and set its metadata at the same time. Like above, you can use// {@link Bucket#upload} to do this, which is just a wrapper around// the following.//-fs.createReadStream('/Users/stephen/Photos/birthday-at-the-zoo/panda.jpg').pipe(file.createWriteStream({metadata: {contentType: 'image/jpeg',metadata: {custom: 'metadata'}}})).on('error', function(err) {}).on('finish', function() {// The file upload is complete.});
method deleteResumableCache
deleteResumableCache: () => void;
Delete failed resumable upload file cache.
Resumable file upload cache the config file to restart upload in case of failure. In certain scenarios, the resumable upload will not works and upload file cache needs to be deleted to upload the same file.
Following are some of the scenarios.
Resumable file upload failed even though the file is successfully saved on the google storage and need to clean up a resumable file cache to update the same file.
Resumable file upload failed due to pre-condition (i.e generation number is not matched) and want to upload a same file with the new generation number.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const myBucket = storage.bucket('my-bucket');const file = myBucket.file('my-file', { generation: 0 });const contents = 'This is the contents of the file.';file.save(contents, function(err) {if (err) {file.deleteResumableCache();}});
method disableAutoRetryConditionallyIdempotent_
disableAutoRetryConditionallyIdempotent_: ( coreOpts: any, methodType: AvailableServiceObjectMethods) => void;
method download
download: { (options?: DownloadOptions): Promise<DownloadResponse>; (options: DownloadOptions, callback: DownloadCallback): void; (callback: DownloadCallback): void;};
method generateSignedPostPolicyV2
generateSignedPostPolicyV2: { ( options: GenerateSignedPostPolicyV2Options ): Promise<GenerateSignedPostPolicyV2Response>; (options: GetSignedPolicyOptions, callback: GetSignedPolicyCallback): void; (callback: GetSignedPolicyCallback): void;};
method generateSignedPostPolicyV4
generateSignedPostPolicyV4: { ( options: GenerateSignedPostPolicyV4Options ): Promise<GenerateSignedPostPolicyV4Response>; ( options: GenerateSignedPostPolicyV4Options, callback: GenerateSignedPostPolicyV4Callback ): void; (callback: GenerateSignedPostPolicyV4Callback): void;};
method getExpirationDate
getExpirationDate: { (): Promise<GetExpirationDateResponse>; (callback: GetExpirationDateCallback): void;};
method getSignedPolicy
getSignedPolicy: { (options: GetSignedPolicyOptions): Promise<GetSignedPolicyResponse>; (options: GetSignedPolicyOptions, callback: GetSignedPolicyCallback): void; (callback: GetSignedPolicyCallback): void;};
method getSignedUrl
getSignedUrl: { (cfg: GetSignedUrlConfig): Promise<GetSignedUrlResponse>; (cfg: GetSignedUrlConfig, callback: GetSignedUrlCallback): void;};
method isPublic
isPublic: { (): Promise<IsPublicResponse>; (callback: IsPublicCallback): void };
method makePrivate
makePrivate: { (options?: MakeFilePrivateOptions): Promise<MakeFilePrivateResponse>; (callback: SetFileMetadataCallback): void; (options: MakeFilePrivateOptions, callback: SetFileMetadataCallback): void;};
method makePublic
makePublic: { (): Promise<MakeFilePublicResponse>; (callback: MakeFilePublicCallback): void;};
method move
move: { ( destination: string | Bucket | File, options?: MoveOptions ): Promise<MoveResponse>; (destination: string | File | Bucket, callback: MoveCallback): void; ( destination: string | File | Bucket, options: MoveOptions, callback: MoveCallback ): void;};
method publicUrl
publicUrl: () => string;
The public URL of this File Use File#makePublic to enable anonymous access via the returned URL.
Returns
{string}
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('albums');const file = bucket.file('my-file');// publicUrl will be "https://storage.googleapis.com/albums/my-file"const publicUrl = file.publicUrl();
method rename
rename: { ( destinationFile: string | File, options?: RenameOptions ): Promise<RenameResponse>; (destinationFile: string | File, callback: MoveCallback): void; ( destinationFile: string | File, options: MoveOptions, callback: MoveCallback ): void;};
method request
request: { (reqOpts: DecorateRequestOptions): Promise<[ResponseBody, Metadata]>; (reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;};
method rotateEncryptionKey
rotateEncryptionKey: { (options?: RotateEncryptionKeyOptions): Promise<RotateEncryptionKeyResponse>; (callback: CopyCallback): void; (options: any, callback: CopyCallback): void;};
method save
save: { (data: string | Buffer, options?: SaveOptions): Promise<void>; (data: any, callback: SaveCallback): void; (data: any, options: SaveOptions, callback: SaveCallback): void;};
method setEncryptionKey
setEncryptionKey: (encryptionKey: string | Buffer) => this;
The Storage API allows you to use a custom key for server-side encryption.
Parameter encryptionKey
An AES-256 encryption key.
Returns
{File}
Example 1
const crypto = require('crypto');const {Storage} = require('@google-cloud/storage');const storage = new Storage();const myBucket = storage.bucket('my-bucket');const encryptionKey = crypto.randomBytes(32);const fileWithCustomEncryption = myBucket.file('my-file');fileWithCustomEncryption.setEncryptionKey(encryptionKey);const fileWithoutCustomEncryption = myBucket.file('my-file');fileWithCustomEncryption.save('data', function(err) {// Try to download with the File object that hasn't had// `setEncryptionKey()` called:fileWithoutCustomEncryption.download(function(err) {// We will receive an error:// err.message === 'Bad Request'// Try again with the File object we called `setEncryptionKey()` on:fileWithCustomEncryption.download(function(err, contents) {// contents.toString() === 'data'});});});Example 2
include:samples/encryption.js region_tag:storage_upload_encrypted_file Example of uploading an encrypted file:
Example 3
include:samples/encryption.js region_tag:storage_download_encrypted_file Example of downloading an encrypted file:
method setStorageClass
setStorageClass: { ( storageClass: string, options?: SetStorageClassOptions ): Promise<SetStorageClassResponse>; ( storageClass: string, options: SetStorageClassOptions, callback: SetStorageClassCallback ): void; (storageClass: string, callback?: SetStorageClassCallback): void;};
method setUserProject
setUserProject: (userProject: string) => void;
Set a user project to be billed for all requests made from this File object.
Parameter userProject
The user project.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('albums');const file = bucket.file('my-file');file.setUserProject('grape-spaceship-123');
method startResumableUpload_
startResumableUpload_: ( dup: Duplexify, options: CreateResumableUploadOptions) => void;
This creates a gcs-resumable-upload upload stream.
Parameter stream
Duplexify stream of data to pipe to the file.
Parameter options
Configuration object.
method startSimpleUpload_
startSimpleUpload_: (dup: Duplexify, options?: CreateWriteStreamOptions) => void;
Takes a readable stream and pipes it to a remote file. Unlike
startResumableUpload_
, which uses the resumable upload technique, this method uses a simple upload (all or nothing).Parameter dup
Duplexify stream of data to pipe to the file.
Parameter options
Configuration object.
class HmacKey
class HmacKey extends ServiceObject<HmacKeyMetadata | undefined> {}
An HmacKey object contains metadata of an HMAC key created from a service account through the Storage client using Storage#createHmacKey.
constructor
constructor(storage: Storage, accessId: string, options?: HmacKeyOptions);
Constructs an HmacKey object.
Note: this only create a local reference to an HMAC key, to create an HMAC key, use Storage#createHmacKey.
Parameter storage
The Storage instance this HMAC key is attached to.
Parameter accessId
The unique accessId for this HMAC key.
Parameter options
Constructor configurations.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const hmacKey = storage.hmacKey('access-id');
property metadata
metadata: HmacKeyMetadata;
class Iam
class Iam {}
Get and set IAM policies for your Cloud Storage bucket.
See Cloud Storage IAM Management See Granting, Changing, and Revoking Access See IAM Roles
Iam
Parameter bucket
The parent instance.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const bucket = storage.bucket('my-bucket');// bucket.iam
constructor
constructor(bucket: Bucket);
method getPolicy
getPolicy: { (options?: GetPolicyOptions): Promise<GetPolicyResponse>; (options: GetPolicyOptions, callback: GetPolicyCallback): void; (callback: GetPolicyCallback): void;};
method setPolicy
setPolicy: { (policy: Policy, options?: SetPolicyOptions): Promise<SetPolicyResponse>; (policy: Policy, callback: SetPolicyCallback): void; ( policy: Policy, options: SetPolicyOptions, callback: SetPolicyCallback ): void;};
method testPermissions
testPermissions: { ( permissions: string | string[], options?: TestIamPermissionsOptions ): Promise<TestIamPermissionsResponse>; (permissions: string | string[], callback: TestIamPermissionsCallback): void; ( permissions: string | string[], options: TestIamPermissionsOptions, callback: TestIamPermissionsCallback ): void;};
class Notification
class Notification extends ServiceObject {}
A Notification object is created from your Bucket object using Bucket#notification. Use it to interact with Cloud Pub/Sub notifications.
See Cloud Pub/Sub Notifications for Google Cloud Storage
Parameter bucket
The bucket instance this notification is attached to.
Parameter id
The ID of the notification.
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const myBucket = storage.bucket('my-bucket');const notification = myBucket.notification('1');
constructor
constructor(bucket: Bucket, id: string);
method delete
delete: { (options?: DeleteNotificationOptions): Promise<[Metadata]>; ( options: DeleteNotificationOptions, callback: DeleteNotificationCallback ): void; (callback: DeleteNotificationCallback): void;};
method get
get: { (options?: GetNotificationOptions): Promise<GetNotificationResponse>; (options: GetNotificationOptions, callback: GetNotificationCallback): void; (callback: GetNotificationCallback): void;};
method getMetadata
getMetadata: { ( options?: GetNotificationMetadataOptions ): Promise<GetNotificationMetadataResponse>; (options: GetNotificationMetadataOptions, callback: MetadataCallback): void; (callback: MetadataCallback): void;};
class Storage
class Storage extends Service {}
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
constructor
constructor(options?: StorageOptions);
Constructs the Storage client.
Parameter options
Configuration options.
Example 1
Create a client that uses Application Default Credentials (ADC)
const {Storage} = require('@google-cloud/storage');const storage = new Storage();Example 2
Create a client with explicit credentials
const storage = new Storage({projectId: 'your-project-id',keyFilename: '/path/to/keyfile.json'});Example 3
Create a client with an
AuthClient
(e.g.DownscopedClient
)const {DownscopedClient} = require('google-auth-library');const authClient = new DownscopedClient({...});const storage = new Storage({authClient});Additional samples: - https://github.com/googleapis/google-auth-library-nodejs#sample-usage-1 - https://github.com/googleapis/google-auth-library-nodejs/blob/main/samples/downscopedclient.js
property acl
static acl: { OWNER_ROLE: string; READER_ROLE: string; WRITER_ROLE: string };
property acl
acl: { OWNER_ROLE: string; READER_ROLE: string; WRITER_ROLE: string };
Reference to Storage.acl.
Storage#acl
See Also
Storage.acl
property Bucket
static Bucket: typeof Bucket;
Bucket class.
Storage.Bucket
See Also
Bucket {Constructor}
property Channel
static Channel: typeof Channel;
Channel class.
Storage.Channel
See Also
Channel {Constructor}
property File
static File: typeof File;
File class.
Storage.File
See Also
File {Constructor}
property HmacKey
static HmacKey: typeof HmacKey;
HmacKey class.
Storage.HmacKey
See Also
HmacKey {Constructor}
property retryOptions
retryOptions: RetryOptions;
method bucket
bucket: (name: string, options?: BucketOptions) => Bucket;
Get a reference to a Cloud Storage bucket.
Parameter name
Name of the bucket.
Parameter options
Configuration object.
Parameter
{string} [options.kmsKeyName] A Cloud KMS key that will be used to encrypt objects inserted into this bucket, if no encryption method is specified.
Parameter
{string} [options.userProject] User project to be billed for all requests made from this Bucket object.
Returns
{Bucket}
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const albums = storage.bucket('albums');const photos = storage.bucket('photos');See Also
Bucket
method channel
channel: (id: string, resourceId: string) => Channel;
Reference a channel to receive notifications about changes to your bucket.
Parameter id
The ID of the channel.
Parameter resourceId
The resource ID of the channel.
Returns
{Channel}
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const channel = storage.channel('id', 'resource-id');See Also
Channel
method createBucket
createBucket: { ( name: string, metadata?: CreateBucketRequest ): Promise<CreateBucketResponse>; (name: string, callback: BucketCallback): void; ( name: string, metadata: CreateBucketRequest, callback: BucketCallback ): void; ( name: string, metadata: CreateBucketRequest, callback: BucketCallback ): void;};
method createHmacKey
createHmacKey: { ( serviceAccountEmail: string, options?: CreateHmacKeyOptions ): Promise<CreateHmacKeyResponse>; (serviceAccountEmail: string, callback: CreateHmacKeyCallback): void; ( serviceAccountEmail: string, options: CreateHmacKeyOptions, callback: CreateHmacKeyCallback ): void;};
method getBuckets
getBuckets: { (options?: GetBucketsRequest): Promise<GetBucketsResponse>; (options: GetBucketsRequest, callback: GetBucketsCallback): void; (callback: GetBucketsCallback): void;};
method getBucketsStream
getBucketsStream: () => Readable;
method getHmacKeys
getHmacKeys: { (options?: GetHmacKeysOptions): Promise<GetHmacKeysResponse>; (callback: GetHmacKeysCallback): void; (options: GetHmacKeysOptions, callback: GetHmacKeysCallback): void;};
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 options
Configuration options.
Parameter callback
Callback function. {Promise}
Example 1
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];});
method getHmacKeysStream
getHmacKeysStream: () => Readable;
method getServiceAccount
getServiceAccount: { (options?: GetServiceAccountOptions): Promise<GetServiceAccountResponse>; (options?: GetServiceAccountOptions): Promise<GetServiceAccountResponse>; ( options: GetServiceAccountOptions, callback: GetServiceAccountCallback ): void; (callback: GetServiceAccountCallback): void;};
method hmacKey
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 theoptions
argument.Parameter accessId
The HMAC key's access ID.
Parameter options
HmacKey constructor options.
Returns
{HmacKey}
Example 1
const {Storage} = require('@google-cloud/storage');const storage = new Storage();const hmacKey = storage.hmacKey('ACCESS_ID');See Also
HmacKey
Interfaces
interface AccessControlObject
interface AccessControlObject {}
interface AclOptions
interface AclOptions {}
property pathPrefix
pathPrefix: string;
property request
request: ( reqOpts: DecorateRequestOptions, callback: BodyResponseCallback) => void;
interface AddAclCallback
interface AddAclCallback {}
call signature
( err: Error | null, acl?: AccessControlObject | null, apiResponse?: Metadata): void;
interface AddAclOptions
interface AddAclOptions {}
property entity
entity: string;
property generation
generation?: number;
property role
role: string;
property userProject
userProject?: string;
interface BucketCallback
interface BucketCallback {}
call signature
(err: Error | null, bucket?: Bucket | null, apiResponse?: Metadata): void;
interface BucketExistsOptions
interface BucketExistsOptions extends GetConfig {}
property userProject
userProject?: string;
interface BucketLockCallback
interface BucketLockCallback {}
call signature
(err?: Error | null, apiResponse?: Metadata): void;
interface BucketOptions
interface BucketOptions {}
property kmsKeyName
kmsKeyName?: string;
property preconditionOpts
preconditionOpts?: PreconditionOptions;
property userProject
userProject?: string;
interface CombineCallback
interface CombineCallback {}
call signature
(err: Error | null, newFile: File | null, apiResponse: Metadata): void;
interface CombineOptions
interface CombineOptions extends PreconditionOptions {}
property kmsKeyName
kmsKeyName?: string;
property userProject
userProject?: string;
interface CopyCallback
interface CopyCallback {}
call signature
(err: Error | null, file?: File | null, apiResponse?: Metadata): void;
interface CopyOptions
interface CopyOptions {}
property cacheControl
cacheControl?: string;
property contentDisposition
contentDisposition?: string;
property contentEncoding
contentEncoding?: string;
property contentType
contentType?: string;
property destinationKmsKeyName
destinationKmsKeyName?: string;
property metadata
metadata?: Metadata;
property preconditionOpts
preconditionOpts?: PreconditionOptions;
property predefinedAcl
predefinedAcl?: string;
property token
token?: string;
property userProject
userProject?: string;
interface CreateBucketQuery
interface CreateBucketQuery {}
property project
project: string;
property userProject
userProject: string;
interface CreateBucketRequest
interface CreateBucketRequest {}
property archive
archive?: boolean;
property coldline
coldline?: boolean;
property cors
cors?: Cors[];
property dra
dra?: boolean;
property location
location?: string;
property multiRegional
multiRegional?: boolean;
property nearline
nearline?: boolean;
property regional
regional?: boolean;
property requesterPays
requesterPays?: boolean;
property retentionPolicy
retentionPolicy?: object;
property rpo
rpo?: string;
property standard
standard?: boolean;
property storageClass
storageClass?: string;
property userProject
userProject?: string;
property versioning
versioning?: Versioning;
interface CreateChannelCallback
interface CreateChannelCallback {}
call signature
(err: Error | null, channel: Channel | null, apiResponse: Metadata): void;
interface CreateChannelConfig
interface CreateChannelConfig extends WatchAllOptions {}
property address
address: string;
interface CreateChannelOptions
interface CreateChannelOptions {}
property userProject
userProject?: string;
interface CreateHmacKeyCallback
interface CreateHmacKeyCallback {}
call signature
( err: Error | null, hmacKey?: HmacKey | null, secret?: string | null, apiResponse?: HmacKeyResourceResponse): void;
interface CreateHmacKeyOptions
interface CreateHmacKeyOptions {}
property projectId
projectId?: string;
property userProject
userProject?: string;
interface CreateNotificationCallback
interface CreateNotificationCallback {}
call signature
( err: Error | null, notification: Notification | null, apiResponse: Metadata): void;
interface CreateNotificationOptions
interface CreateNotificationOptions {}
property customAttributes
customAttributes?: { [key: string]: string;};
property eventTypes
eventTypes?: string[];
property objectNamePrefix
objectNamePrefix?: string;
property payloadFormat
payloadFormat?: string;
property userProject
userProject?: string;
interface CreateReadStreamOptions
interface CreateReadStreamOptions {}
property decompress
decompress?: boolean;
property end
end?: number;
property start
start?: number;
property userProject
userProject?: string;
property validation
validation?: 'md5' | 'crc32c' | false | true;
interface CreateResumableUploadCallback
interface CreateResumableUploadCallback {}
call signature
(err: Error | null, uri?: string): void;
interface CreateResumableUploadOptions
interface CreateResumableUploadOptions {}
property chunkSize
chunkSize?: number;
property configPath
configPath?: string;
property metadata
metadata?: Metadata;
property offset
offset?: number;
property origin
origin?: string;
property preconditionOpts
preconditionOpts?: PreconditionOptions;
property predefinedAcl
predefinedAcl?: PredefinedAcl;
property private
private?: boolean;
property public
public?: boolean;
property uri
uri?: string;
property userProject
userProject?: string;
interface CreateWriteStreamOptions
interface CreateWriteStreamOptions extends CreateResumableUploadOptions {}
property contentType
contentType?: string;
property gzip
gzip?: string | boolean;
property resumable
resumable?: boolean;
property timeout
timeout?: number;
property validation
validation?: string | boolean;
interface DeleteBucketCallback
interface DeleteBucketCallback extends DeleteCallback {}
call signature
(err: Error | null, apiResponse: Metadata): void;
interface DeleteBucketOptions
interface DeleteBucketOptions {}
property ignoreNotFound
ignoreNotFound?: boolean;
property userProject
userProject?: string;
interface DeleteFileCallback
interface DeleteFileCallback {}
call signature
(err: Error | null, apiResponse?: Metadata): void;
interface DeleteFileOptions
interface DeleteFileOptions {}
property ignoreNotFound
ignoreNotFound?: boolean;
property userProject
userProject?: string;
interface DeleteFilesCallback
interface DeleteFilesCallback {}
call signature
(err: Error | Error[] | null, apiResponse?: object): void;
interface DeleteFilesOptions
interface DeleteFilesOptions extends GetFilesOptions, PreconditionOptions {}
property force
force?: boolean;
interface DeleteNotificationCallback
interface DeleteNotificationCallback {}
DeleteNotificationCallback
Parameter err
Request error, if any.
Parameter apiResponse
The full API response.
call signature
(err: Error | null, apiResponse?: Metadata): void;
interface DeleteNotificationOptions
interface DeleteNotificationOptions {}
property userProject
userProject?: string;
interface DisableRequesterPaysCallback
interface DisableRequesterPaysCallback {}
call signature
(err?: Error | null, apiResponse?: object): void;
interface DownloadOptions
interface DownloadOptions extends CreateReadStreamOptions {}
property destination
destination?: string;
interface EnableRequesterPaysCallback
interface EnableRequesterPaysCallback {}
call signature
(err?: Error | null, apiResponse?: Metadata): void;
interface EncryptionKeyOptions
interface EncryptionKeyOptions {}
property encryptionKey
encryptionKey?: string | Buffer;
property kmsKeyName
kmsKeyName?: string;
interface FileExistsCallback
interface FileExistsCallback {}
call signature
(err: Error | null, exists?: boolean): void;
interface FileExistsOptions
interface FileExistsOptions {}
property userProject
userProject?: string;
interface FileOptions
interface FileOptions {}
property encryptionKey
encryptionKey?: string | Buffer;
property generation
generation?: number | string;
property kmsKeyName
kmsKeyName?: string;
property preconditionOpts
preconditionOpts?: PreconditionOptions;
property userProject
userProject?: string;
interface GenerateSignedPostPolicyV4Callback
interface GenerateSignedPostPolicyV4Callback {}
call signature
(err: Error | null, output?: SignedPostPolicyV4Output): void;
interface GenerateSignedPostPolicyV4Options
interface GenerateSignedPostPolicyV4Options {}
property bucketBoundHostname
bucketBoundHostname?: string;
property conditions
conditions?: object[];
property expires
expires: string | number | Date;
property fields
fields?: PolicyFields;
property virtualHostedStyle
virtualHostedStyle?: boolean;
interface GetAclCallback
interface GetAclCallback {}
call signature
( err: Error | null, acl?: AccessControlObject | AccessControlObject[] | null, apiResponse?: Metadata): void;
interface GetAclOptions
interface GetAclOptions {}
property entity
entity: string;
property generation
generation?: number;
property userProject
userProject?: string;
interface GetBucketCallback
interface GetBucketCallback {}
call signature
(err: ApiError | null, bucket: Bucket | null, apiResponse: Metadata): void;
interface GetBucketMetadataCallback
interface GetBucketMetadataCallback {}
call signature
(err: ApiError | null, metadata: Metadata | null, apiResponse: Metadata): void;
interface GetBucketMetadataOptions
interface GetBucketMetadataOptions {}
property userProject
userProject?: string;
interface GetBucketOptions
interface GetBucketOptions extends GetConfig {}
property userProject
userProject?: string;
interface GetBucketsCallback
interface GetBucketsCallback {}
call signature
( err: Error | null, buckets: Bucket[], nextQuery?: {}, apiResponse?: Metadata): void;
interface GetBucketSignedUrlConfig
interface GetBucketSignedUrlConfig {}
property action
action: 'list';
property cname
cname?: string;
property expires
expires: string | number | Date;
property extensionHeaders
extensionHeaders?: http.OutgoingHttpHeaders;
property queryParams
queryParams?: Query;
property version
version?: 'v2' | 'v4';
property virtualHostedStyle
virtualHostedStyle?: boolean;
interface GetBucketsRequest
interface GetBucketsRequest {}
property autoPaginate
autoPaginate?: boolean;
property maxApiCalls
maxApiCalls?: number;
property maxResults
maxResults?: number;
property pageToken
pageToken?: string;
property prefix
prefix?: string;
property project
project?: string;
property userProject
userProject?: string;
interface GetExpirationDateCallback
interface GetExpirationDateCallback {}
call signature
(err: Error | null, expirationDate?: Date | null, apiResponse?: Metadata): void;
interface GetFileCallback
interface GetFileCallback {}
call signature
(err: Error | null, file?: File, apiResponse?: Metadata): void;
interface GetFileMetadataCallback
interface GetFileMetadataCallback {}
call signature
(err: Error | null, metadata?: Metadata, apiResponse?: Metadata): void;
interface GetFileMetadataOptions
interface GetFileMetadataOptions {}
property userProject
userProject?: string;
interface GetFileOptions
interface GetFileOptions extends GetConfig {}
property userProject
userProject?: string;
interface GetFilesCallback
interface GetFilesCallback {}
call signature
( err: Error | null, files?: File[], nextQuery?: {}, apiResponse?: Metadata): void;
interface GetFilesOptions
interface GetFilesOptions {}
property autoPaginate
autoPaginate?: boolean;
property delimiter
delimiter?: string;
property endOffset
endOffset?: string;
property includeTrailingDelimiter
includeTrailingDelimiter?: boolean;
property maxApiCalls
maxApiCalls?: number;
property maxResults
maxResults?: number;
property pageToken
pageToken?: string;
property prefix
prefix?: string;
property startOffset
startOffset?: string;
property userProject
userProject?: string;
property versions
versions?: boolean;
interface GetHmacKeysCallback
interface GetHmacKeysCallback {}
call signature
( err: Error | null, hmacKeys: HmacKey[] | null, nextQuery?: {}, apiResponse?: Metadata): void;
interface GetHmacKeysOptions
interface GetHmacKeysOptions {}
property autoPaginate
autoPaginate?: boolean;
property maxApiCalls
maxApiCalls?: number;
property maxResults
maxResults?: number;
property pageToken
pageToken?: string;
property projectId
projectId?: string;
property serviceAccountEmail
serviceAccountEmail?: string;
property showDeletedKeys
showDeletedKeys?: boolean;
property userProject
userProject?: string;
interface GetLabelsCallback
interface GetLabelsCallback {}
call signature
(err: Error | null, labels: object | null): void;
interface GetLabelsOptions
interface GetLabelsOptions {}
property userProject
userProject?: string;
interface GetNotificationCallback
interface GetNotificationCallback {}
GetNotificationCallback
Parameter err
Request error, if any.
Parameter notification
The Notification.
Parameter apiResponse
The full API response.
call signature
( err: Error | null, notification?: Notification | null, apiResponse?: Metadata): void;
interface GetNotificationMetadataCallback
interface GetNotificationMetadataCallback {}
GetNotificationMetadataCallback
Parameter err
Request error, if any.
Parameter files
The notification metadata.
Parameter apiResponse
The full API response.
call signature
(err: Error | null, metadata?: ResponseBody, apiResponse?: Metadata): void;
interface GetNotificationMetadataOptions
interface GetNotificationMetadataOptions {}
property userProject
userProject?: string;
interface GetNotificationOptions
interface GetNotificationOptions {}
property autoCreate
autoCreate?: boolean;
Automatically create the object if it does not exist. Default:
false
.
property userProject
userProject?: string;
The ID of the project which will be billed for the request.
interface GetNotificationsCallback
interface GetNotificationsCallback {}
call signature
( err: Error | null, notifications: Notification[] | null, apiResponse: Metadata): void;
interface GetNotificationsOptions
interface GetNotificationsOptions {}
property userProject
userProject?: string;
interface GetPolicyCallback
interface GetPolicyCallback {}
GetPolicyCallback
Parameter err
Request error, if any.
Parameter acl
The policy.
Parameter apiResponse
The full API response.
call signature
(err?: Error | null, acl?: Policy, apiResponse?: Metadata): void;
interface GetPolicyOptions
interface GetPolicyOptions {}
property requestedPolicyVersion
requestedPolicyVersion?: number;
property userProject
userProject?: string;
interface GetServiceAccountCallback
interface GetServiceAccountCallback {}
call signature
( err: Error | null, serviceAccount?: ServiceAccount, apiResponse?: Metadata): void;
interface GetServiceAccountOptions
interface GetServiceAccountOptions {}
property userProject
userProject?: string;
interface GetSignedPolicyCallback
interface GetSignedPolicyCallback {}
call signature
(err: Error | null, policy?: PolicyDocument): void;
interface GetSignedPolicyOptions
interface GetSignedPolicyOptions {}
property acl
acl?: string;
property contentLengthRange
contentLengthRange?: { min?: number; max?: number;};
property equals
equals?: string[] | string[][];
property expires
expires: string | number | Date;
property startsWith
startsWith?: string[] | string[][];
property successRedirect
successRedirect?: string;
property successStatus
successStatus?: string;
interface GetSignedUrlCallback
interface GetSignedUrlCallback {}
call signature
(err: Error | null, url?: string): void;
interface GetSignedUrlConfig
interface GetSignedUrlConfig {}
property accessibleAt
accessibleAt?: string | number | Date;
property action
action: 'read' | 'write' | 'delete' | 'resumable';
property cname
cname?: string;
property contentMd5
contentMd5?: string;
property contentType
contentType?: string;
property expires
expires: string | number | Date;
property extensionHeaders
extensionHeaders?: http.OutgoingHttpHeaders;
property promptSaveAs
promptSaveAs?: string;
property queryParams
queryParams?: Query;
property responseDisposition
responseDisposition?: string;
property responseType
responseType?: string;
property version
version?: 'v2' | 'v4';
property virtualHostedStyle
virtualHostedStyle?: boolean;
interface HmacKeyMetadata
interface HmacKeyMetadata {}
property accessId
accessId: string;
property etag
etag?: string;
property id
id?: string;
property projectId
projectId?: string;
property serviceAccountEmail
serviceAccountEmail?: string;
property state
state?: string;
property timeCreated
timeCreated?: string;
property updated
updated?: string;
interface HmacKeyMetadataCallback
interface HmacKeyMetadataCallback {}
call signature
(err: Error | null, metadata?: HmacKeyMetadata, apiResponse?: Metadata): void;
interface HmacKeyResourceResponse
interface HmacKeyResourceResponse {}
interface Labels
interface Labels {}
index signature
[key: string]: string;
interface MakeBucketPrivateCallback
interface MakeBucketPrivateCallback {}
call signature
(err?: Error | null, files?: File[]): void;
interface MakeBucketPrivateOptions
interface MakeBucketPrivateOptions {}
property force
force?: boolean;
property includeFiles
includeFiles?: boolean;
property metadata
metadata?: Metadata;
property userProject
userProject?: string;
interface MakeBucketPublicCallback
interface MakeBucketPublicCallback {}
call signature
(err?: Error | null, files?: File[]): void;
interface MakeBucketPublicOptions
interface MakeBucketPublicOptions {}
property force
force?: boolean;
property includeFiles
includeFiles?: boolean;
interface MakeFilePrivateOptions
interface MakeFilePrivateOptions {}
property metadata
metadata?: Metadata;
property strict
strict?: boolean;
property userProject
userProject?: string;
interface MakeFilePublicCallback
interface MakeFilePublicCallback {}
call signature
(err?: Error | null, apiResponse?: Metadata): void;
interface MoveCallback
interface MoveCallback {}
call signature
(err: Error | null, destinationFile?: File | null, apiResponse?: Metadata): void;
interface MoveOptions
interface MoveOptions {}
property preconditionOpts
preconditionOpts?: PreconditionOptions;
property userProject
userProject?: string;
interface Policy
interface Policy {}
interface PolicyDocument
interface PolicyDocument {}
interface PolicyFields
interface PolicyFields {}
index signature
[key: string]: string;
interface PreconditionOptions
interface PreconditionOptions {}
property ifGenerationMatch
ifGenerationMatch?: number;
property ifGenerationNotMatch
ifGenerationNotMatch?: number;
property ifMetagenerationMatch
ifMetagenerationMatch?: number;
property ifMetagenerationNotMatch
ifMetagenerationNotMatch?: number;
interface RemoveAclCallback
interface RemoveAclCallback {}
call signature
(err: Error | null, apiResponse?: Metadata): void;
interface RemoveAclOptions
interface RemoveAclOptions {}
property entity
entity: string;
property generation
generation?: number;
property userProject
userProject?: string;
interface SaveCallback
interface SaveCallback {}
call signature
(err?: Error | null): void;
interface SaveOptions
interface SaveOptions extends CreateWriteStreamOptions {}
property onUploadProgress
onUploadProgress?: (progressEvent: any) => void;
interface ServiceAccount
interface ServiceAccount {}
property emailAddress
emailAddress?: string;
interface SetBucketMetadataCallback
interface SetBucketMetadataCallback {}
call signature
(err?: Error | null, metadata?: Metadata): void;
interface SetBucketMetadataOptions
interface SetBucketMetadataOptions {}
property userProject
userProject?: string;
interface SetBucketStorageClassCallback
interface SetBucketStorageClassCallback {}
call signature
(err?: Error | null): void;
interface SetBucketStorageClassOptions
interface SetBucketStorageClassOptions {}
property userProject
userProject?: string;
interface SetFileMetadataCallback
interface SetFileMetadataCallback {}
call signature
(err?: Error | null, apiResponse?: Metadata): void;
interface SetFileMetadataOptions
interface SetFileMetadataOptions {}
property userProject
userProject?: string;
interface SetHmacKeyMetadata
interface SetHmacKeyMetadata {}
interface SetHmacKeyMetadataOptions
interface SetHmacKeyMetadataOptions {}
property userProject
userProject?: string;
This parameter is currently ignored.
interface SetLabelsCallback
interface SetLabelsCallback {}
call signature
(err?: Error | null, metadata?: Metadata): void;
interface SetLabelsOptions
interface SetLabelsOptions {}
property userProject
userProject?: string;
interface SetPolicyCallback
interface SetPolicyCallback {}
SetPolicyCallback
Parameter err
Request error, if any.
Parameter acl
The policy.
Parameter apiResponse
The full API response.
call signature
(err?: Error | null, acl?: Policy, apiResponse?: object): void;
interface SetPolicyOptions
interface SetPolicyOptions {}
{object} SetPolicyOptions
Parameter userProject
The ID of the project which will be billed for the request.
property userProject
userProject?: string;
interface SetStorageClassCallback
interface SetStorageClassCallback {}
call signature
(err?: Error | null, apiResponse?: Metadata): void;
interface SetStorageClassOptions
interface SetStorageClassOptions {}
property preconditionOpts
preconditionOpts?: PreconditionOptions;
property userProject
userProject?: string;
interface SignedPostPolicyV4Output
interface SignedPostPolicyV4Output {}
interface StopCallback
interface StopCallback {}
call signature
(err: Error | null, apiResponse?: Metadata): void;
interface StorageOptions
interface StorageOptions extends ServiceOptions {}
property apiEndpoint
apiEndpoint?: string;
The API endpoint of the service used to make requests. Defaults to
storage.googleapis.com
.
property promise
promise?: typeof Promise;
**This option is deprecated.** Remove in next major release.
property retryOptions
retryOptions?: RetryOptions;
interface TestIamPermissionsCallback
interface TestIamPermissionsCallback {}
TestIamPermissionsCallback
Parameter err
Request error, if any.
Parameter acl
A subset of permissions that the caller is allowed.
Parameter apiResponse
The full API response.
call signature
( err?: Error | null, acl?: { [key: string]: boolean; } | null, apiResponse?: Metadata): void;
interface TestIamPermissionsOptions
interface TestIamPermissionsOptions {}
{object} TestIamPermissionsOptions Configuration options for Iam#testPermissions().
Parameter userProject
The ID of the project which will be billed for the request.
property userProject
userProject?: string;
interface UpdateAclCallback
interface UpdateAclCallback {}
call signature
( err: Error | null, acl?: AccessControlObject | null, apiResponse?: Metadata): void;
interface UpdateAclOptions
interface UpdateAclOptions {}
property entity
entity: string;
property generation
generation?: number;
property role
role: string;
property userProject
userProject?: string;
interface UploadCallback
interface UploadCallback {}
call signature
(err: Error | null, file?: File | null, apiResponse?: Metadata): void;
interface UploadOptions
interface UploadOptions extends CreateResumableUploadOptions, CreateWriteStreamOptions {}
property destination
destination?: string | File;
property encryptionKey
encryptionKey?: string | Buffer;
property kmsKeyName
kmsKeyName?: string;
property onUploadProgress
onUploadProgress?: (progressEvent: any) => void;
property resumable
resumable?: boolean;
property timeout
timeout?: number;
Enums
enum IdempotencyStrategy
enum IdempotencyStrategy { RetryAlways = 0, RetryConditional = 1, RetryNever = 2,}
member RetryAlways
RetryAlways = 0
member RetryConditional
RetryConditional = 1
member RetryNever
RetryNever = 2
Type Aliases
type AddAclResponse
type AddAclResponse = [AccessControlObject, Metadata];
type BucketExistsCallback
type BucketExistsCallback = ExistsCallback;
type BucketExistsResponse
type BucketExistsResponse = [boolean];
type BucketLockResponse
type BucketLockResponse = [Metadata];
type CombineResponse
type CombineResponse = [File, Metadata];
type CopyResponse
type CopyResponse = [File, Metadata];
type CreateBucketResponse
type CreateBucketResponse = [Bucket, Metadata];
type CreateChannelResponse
type CreateChannelResponse = [Channel, Metadata];
type CreateHmacKeyResponse
type CreateHmacKeyResponse = [HmacKey, string, HmacKeyResourceResponse];
type CreateNotificationResponse
type CreateNotificationResponse = [Notification, Metadata];
type CreateResumableUploadResponse
type CreateResumableUploadResponse = [string];
type DeleteBucketResponse
type DeleteBucketResponse = [Metadata];
type DeleteFileResponse
type DeleteFileResponse = [Metadata];
type DeleteLabelsCallback
type DeleteLabelsCallback = SetLabelsCallback;
type DeleteLabelsResponse
type DeleteLabelsResponse =