Skip to content

Latest commit

 

History

History
2094 lines (829 loc) · 54.9 KB

README.md

File metadata and controls

2094 lines (829 loc) · 54.9 KB

Google Cloud Platform logo

Open in Cloud Shell

Node.js idiomatic client for Cloud Storage.

Cloud Storage allows world-wide storage and retrieval of any amount of data at any time. You can use Google Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.

Table of Contents

Before you begin

Before running the samples, make sure you've followed the steps outlined in Using the client library.

cd samples

npm install

cd ..

Samples

Add Bucket Conditional Binding

View the source code.

Open in Cloud Shell

Usage:

node samples/addBucketConditionalBinding.js


Add Bucket Default Owner Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/addBucketDefaultOwnerAcl.js


Add Bucket Iam Member

View the source code.

Open in Cloud Shell

Usage:

node samples/addBucketIamMember.js


Storage Add Bucket Label.

Adds bucket label.

View the source code.

Open in Cloud Shell

Usage:

node addBucketLabel.js <BUCKET_NAME> <LABEL_KEY> <LABEL_VALUE>


Add Bucket Owner Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/addBucketOwnerAcl.js


Bucket Website Configuration.

Bucket Website Configuration.

View the source code.

Open in Cloud Shell

Usage:

node addBucketWebsiteConfiguration.js <BUCKET_NAME> <MAIN_PAGE_SUFFIX> <NOT_FOUND_PAGE>


Add File Owner Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/addFileOwnerAcl.js


Storage Get Bucket Metadata.

Get bucket metadata.

View the source code.

Open in Cloud Shell

Usage:

node bucketMetadata.js <BUCKET_NAME>


Change Bucket's Default Storage Class.

Change Bucket's Default Storage Class.

View the source code.

Open in Cloud Shell

Usage:

node changeDefaultStorageClass.js <BUCKET_NAME> <CLASS_NAME>


Storage File Convert CSEK to CMEK.

Storage File Convert CSEK to CMEK.

View the source code.

Open in Cloud Shell

Usage:

node changeFileCSEKToCMEK.js <BUCKET_NAME> <FILE_NAME> <ENCRYPTION_KEY> <KMS_KEY_NAME>


Storage Combine files.

Combine multiple files into one new file.

View the source code.

Open in Cloud Shell

Usage:

node composeFile.js <BUCKET_NAME> <FIRST_FILE_NAME> <SECOND_FILE_NAME> <DESTINATION_FILE_NAME>


Storage Configure Bucket Cors.

Configures bucket cors.

View the source code.

Open in Cloud Shell

Usage:

node configureBucketCors.js <BUCKET_NAME> <MAX_AGE_SECONDS> <METHOD> <ORIGIN> <RESPONSE_HEADER>


Configure Retries

View the source code.

Open in Cloud Shell

Usage:

node samples/configureRetries.js


Copy File

View the source code.

Open in Cloud Shell

Usage:

node samples/copyFile.js


Copy Old Version Of File.

Copy Old Version Of File.

View the source code.

Open in Cloud Shell

Usage:

node copyOldVersionOfFile.js <SRC_BUCKET_NAME> <SRC_FILE_NAME> <DEST_BUCKET_NAME> <DEST_FILE_NAME> <GENERATION>


Create a Dual-Region Bucket

Create a Dual-Region Bucket with provided location and regions.

View the source code.

Open in Cloud Shell

Usage:

node createBucketWithDualRegion.js <BUCKET_NAME> <LOCATION> <REGION1> <REGION2>


Create Bucket With Storage Class and Location.

Create Bucket With Storage Class and Location.

View the source code.

Open in Cloud Shell

Usage:

node createBucketWithStorageClassAndLocation.js <BUCKET_NAME> <CLASS_NAME> <LOCATION>


Create Bucket With Turbo Replication

View the source code.

Open in Cloud Shell

Usage:

node samples/createBucketWithTurboReplication.js


Create New Bucket

View the source code.

Open in Cloud Shell

Usage:

node samples/createNewBucket.js


Create Notification

View the source code.

Open in Cloud Shell

Usage:

node samples/createNotification.js


Delete Bucket

View the source code.

Open in Cloud Shell

Usage:

node samples/deleteBucket.js


Delete File

View the source code.

Open in Cloud Shell

Usage:

node samples/deleteFile.js


Delete Notification

View the source code.

Open in Cloud Shell

Usage:

node samples/deleteNotification.js


Delete Old Version Of File.

Delete Old Version Of File.

View the source code.

Open in Cloud Shell

Usage:

node deleteOldVersionOfFile.js <BUCKET_NAME> <FILE_NAME> <GENERATION>


Disable Bucket Lifecycle Management

View the source code.

Open in Cloud Shell

Usage:

node samples/disableBucketLifecycleManagement.js


Storage Disable Bucket Versioning.

Disables bucket versioning.

View the source code.

Open in Cloud Shell

Usage:

node disableBucketVersioning.js <BUCKET_NAME>


Disable Default Event Based Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/disableDefaultEventBasedHold.js


Disable Requester Pays

View the source code.

Open in Cloud Shell

Usage:

node samples/disableRequesterPays.js


Disable Uniform Bucket Level Access

View the source code.

Open in Cloud Shell

Usage:

node samples/disableUniformBucketLevelAccess.js


Download Byte Range

View the source code.

Open in Cloud Shell

Usage:

node samples/downloadByteRange.js


Download Encrypted File

View the source code.

Open in Cloud Shell

Usage:

node samples/downloadEncryptedFile.js


Download File

View the source code.

Open in Cloud Shell

Usage:

node samples/downloadFile.js


Download File Using Requester Pays

View the source code.

Open in Cloud Shell

Usage:

node samples/downloadFileUsingRequesterPays.js


Download Into Memory

View the source code.

Open in Cloud Shell

Usage:

node samples/downloadIntoMemory.js


Storage Download Public File.

Download Public File.

View the source code.

Open in Cloud Shell

Usage:

node downloadPublicFile.js <BUCKET_NAME> <SRC_FILE_NAME> <DEST_FILE_NAME>


Enable Bucket Lifecycle Management

View the source code.

Open in Cloud Shell

Usage:

node samples/enableBucketLifecycleManagement.js


Storage Enable Bucket Versioning.

Enables bucket versioning.

View the source code.

Open in Cloud Shell

Usage:

node enableBucketVersioning.js <BUCKET_NAME>


Enable Default Event Based Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/enableDefaultEventBasedHold.js


Enable Default KMS Key

View the source code.

Open in Cloud Shell

Usage:

node samples/enableDefaultKMSKey.js


Enable Requester Pays

View the source code.

Open in Cloud Shell

Usage:

node samples/enableRequesterPays.js


Enable Uniform Bucket Level Access

View the source code.

Open in Cloud Shell

Usage:

node samples/enableUniformBucketLevelAccess.js


Change File's Storage Class.

Change File's Storage Class.

View the source code.

Open in Cloud Shell

Usage:

node fileChangeStorageClass.js <BUCKET_NAME> <FILE_NAME> <CLASS_NAME>


Storage Set File Metadata.

Set file metadata.

View the source code.

Open in Cloud Shell

Usage:

node fileSetMetadata.js <BUCKET_NAME> <FILE_NAME>


Generate Encryption Key

View the source code.

Open in Cloud Shell

Usage:

node samples/generateEncryptionKey.js


Generate Signed Url

View the source code.

Open in Cloud Shell

Usage:

node samples/generateSignedUrl.js


Generate V4 Read Signed Url

View the source code.

Open in Cloud Shell

Usage:

node samples/generateV4ReadSignedUrl.js


Generate V4 Signed Policy

View the source code.

Open in Cloud Shell

Usage:

node samples/generateV4SignedPolicy.js


Generate V4 Upload Signed Url

View the source code.

Open in Cloud Shell

Usage:

node samples/generateV4UploadSignedUrl.js


Get Autoclass

View the source code.

Open in Cloud Shell

Usage:

node samples/getAutoclass.js


Get Default Event Based Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/getDefaultEventBasedHold.js


Get Metadata

View the source code.

Open in Cloud Shell

Usage:

node samples/getMetadata.js


Get Metadata Notifications

View the source code.

Open in Cloud Shell

Usage:

node samples/getMetadataNotifications.js


Get Public Access Prevention

View the source code.

Open in Cloud Shell

Usage:

node samples/getPublicAccessPrevention.js


Get RPO

View the source code.

Open in Cloud Shell

Usage:

node samples/getRPO.js


Get Requester Pays Status

View the source code.

Open in Cloud Shell

Usage:

node samples/getRequesterPaysStatus.js


Get Retention Policy

View the source code.

Open in Cloud Shell

Usage:

node samples/getRetentionPolicy.js


Storage Get Service Account.

Get Service Account.

View the source code.

Open in Cloud Shell

Usage:

node getServiceAccount.js <PROJECT_ID>


Get Uniform Bucket Level Access

View the source code.

Open in Cloud Shell

Usage:

node samples/getUniformBucketLevelAccess.js


Activate HMAC SA Key.

Activate HMAC SA Key.

View the source code.

Open in Cloud Shell

Usage:

node hmacKeyActivate.js <hmacKeyAccessId> [projectId]


Create HMAC SA Key.

Create HMAC SA Key.

View the source code.

Open in Cloud Shell

Usage:

node hmacKeyCreate.js <serviceAccountEmail> [projectId]


Deactivate HMAC SA Key.

Deactivate HMAC SA Key.

View the source code.

Open in Cloud Shell

Usage:

node hmacKeyDeactivate.js <hmacKeyAccessId> [projectId]


Delete HMAC SA Key.

Delete HMAC SA Key.

View the source code.

Open in Cloud Shell

Usage:

node hmacKeyDelete.js <hmacKeyAccessId> [projectId]


Get HMAC SA Key Metadata.

Get HMAC SA Key Metadata.

View the source code.

Open in Cloud Shell

Usage:

node hmacKeyGet.js <hmacKeyAccessId> [projectId]


List HMAC SA Keys Metadata.

List HMAC SA Keys Metadata.

View the source code.

Open in Cloud Shell

Usage:

node hmacKeyList.js [projectId]


List Buckets

View the source code.

Open in Cloud Shell

Usage:

node samples/listBuckets.js


List Files

View the source code.

Open in Cloud Shell

Usage:

node samples/listFiles.js


List Files By Prefix

View the source code.

Open in Cloud Shell

Usage:

node samples/listFilesByPrefix.js


List Files Paginate

View the source code.

Open in Cloud Shell

Usage:

node samples/listFilesPaginate.js


List Files with Old Versions.

List Files with Old Versions.

View the source code.

Open in Cloud Shell

Usage:

node listFilesWithOldVersions.js <BUCKET_NAME>


List Notifications

View the source code.

Open in Cloud Shell

Usage:

node samples/listNotifications.js


Lock Retention Policy

View the source code.

Open in Cloud Shell

Usage:

node samples/lockRetentionPolicy.js


Storage Make Bucket Public.

Storage Make Bucket Public.

View the source code.

Open in Cloud Shell

Usage:

node makeBucketPublic.js <BUCKET_NAME>


Make Public

View the source code.

Open in Cloud Shell

Usage:

node samples/makePublic.js


Move File

View the source code.

Open in Cloud Shell

Usage:

node samples/moveFile.js


Print Bucket Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/printBucketAcl.js


Print Bucket Acl For User

View the source code.

Open in Cloud Shell

Usage:

node samples/printBucketAclForUser.js


Print File Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/printFileAcl.js


Print File Acl For User

View the source code.

Open in Cloud Shell

Usage:

node samples/printFileAclForUser.js


Quickstart

View the source code.

Open in Cloud Shell

Usage:

node samples/quickstart.js


Release Event Based Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/releaseEventBasedHold.js


Release Temporary Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/releaseTemporaryHold.js


Remove Bucket Conditional Binding

View the source code.

Open in Cloud Shell

Usage:

node samples/removeBucketConditionalBinding.js


Storage Remove Bucket Cors Configuration.

Removes bucket cors configuration.

View the source code.

Open in Cloud Shell

Usage:

node removeBucketCors.js <BUCKET_NAME>


Remove Bucket Default Owner

View the source code.

Open in Cloud Shell

Usage:

node samples/removeBucketDefaultOwner.js


Remove Bucket Iam Member

View the source code.

Open in Cloud Shell

Usage:

node samples/removeBucketIamMember.js


Storage Remove Bucket Label.

Removes bucket label.

View the source code.

Open in Cloud Shell

Usage:

node removeBucketLabel.js <BUCKET_NAME> labelone)


Remove Bucket Owner Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/removeBucketOwnerAcl.js


Remove Default KMS Key.

Remove Default KMS Key.

View the source code.

Open in Cloud Shell

Usage:

node removeDefaultKMSKey.js <BUCKET_NAME>


Remove File Owner Acl

View the source code.

Open in Cloud Shell

Usage:

node samples/removeFileOwnerAcl.js


Remove Retention Policy

View the source code.

Open in Cloud Shell

Usage:

node samples/removeRetentionPolicy.js


Rename File

View the source code.

Open in Cloud Shell

Usage:

node samples/renameFile.js


Rotate Encryption Key

View the source code.

Open in Cloud Shell

Usage:

node samples/rotateEncryptionKey.js


Set Autoclass

View the source code.

Open in Cloud Shell

Usage:

node samples/setAutoclass.js


Set Client Endpoint

View the source code.

Open in Cloud Shell

Usage:

node samples/setClientEndpoint.js


Set Event Based Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/setEventBasedHold.js


Set Public Access Prevention Enforced

View the source code.

Open in Cloud Shell

Usage:

node samples/setPublicAccessPreventionEnforced.js


Set Public Access Prevention Inherited

View the source code.

Open in Cloud Shell

Usage:

node samples/setPublicAccessPreventionInherited.js


Set RPO Async Turbo

View the source code.

Open in Cloud Shell

Usage:

node samples/setRPOAsyncTurbo.js


Set RPO Default

View the source code.

Open in Cloud Shell

Usage:

node samples/setRPODefault.js


Set Retention Policy

View the source code.

Open in Cloud Shell

Usage:

node samples/setRetentionPolicy.js


Set Temporary Hold

View the source code.

Open in Cloud Shell

Usage:

node samples/setTemporaryHold.js


Stream File Download

View the source code.

Open in Cloud Shell

Usage:

node samples/streamFileDownload.js


Stream File Upload

View the source code.

Open in Cloud Shell

Usage:

node samples/streamFileUpload.js


Upload a directory to a bucket.

Uploads full hierarchy of a local directory to a bucket.

View the source code.

Open in Cloud Shell

Usage:

node files.js upload-directory <bucketName> <directoryPath>


Upload Encrypted File

View the source code.

Open in Cloud Shell

Usage:

node samples/uploadEncryptedFile.js


Upload File

View the source code.

Open in Cloud Shell

Usage:

node samples/uploadFile.js


Upload File With Kms Key

View the source code.

Open in Cloud Shell

Usage:

node samples/uploadFileWithKmsKey.js


Upload From Memory

View the source code.

Open in Cloud Shell

Usage:

node samples/uploadFromMemory.js


Upload Without Authentication

View the source code.

Open in Cloud Shell

Usage:

node samples/uploadWithoutAuthentication.js


Upload Without Authentication Signed Url

View the source code.

Open in Cloud Shell

Usage:

node samples/uploadWithoutAuthenticationSignedUrl.js


View Bucket Iam Members

View the source code.

Open in Cloud Shell

Usage:

node samples/viewBucketIamMembers.js