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.
- Google Cloud Storage Node.js Client API Reference
- Google Cloud Storage Documentation
- github.com/googleapis/nodejs-storage
Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.
Table of contents:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Google Cloud Storage API.
- Set up authentication with a service account so you can access the API from your local workstation.
npm install @google-cloud/storage
// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');
// Creates a client
const storage = new Storage();
// Creates a client from a Google service account key.
// const storage = new Storage({keyFilename: "key.json"});
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// const bucketName = 'bucket-name';
async function createBucket() {
// Creates the new bucket
await storage.createBucket(bucketName);
console.log(`Bucket ${bucketName} created.`);
}
createBucket().catch(console.error);
Samples are in the samples/
directory. The samples' README.md
has instructions for running the samples.
Sample | Source Code | Try it |
---|---|---|
Add Bucket Conditional Binding | source code | |
Add Bucket Default Owner Acl | source code | |
Add Bucket Iam Member | source code | |
Add Bucket Owner Acl | source code | |
Add File Owner Acl | source code | |
Storage Get Bucket Metadata. | source code | |
Copy File | source code | |
Create New Bucket | source code | |
Create Notification | source code | |
Delete Bucket | source code | |
Delete File | source code | |
Delete Notification | source code | |
Disable Default Event Based Hold | source code | |
Disable Requester Pays | source code | |
Disable Uniform Bucket Level Access | source code | |
Download Encrypted File | source code | |
Download File | source code | |
Download File Using Requester Pays | source code | |
Enable Default Event Based Hold | source code | |
Enable Default KMS Key | source code | |
Enable Requester Pays | source code | |
Enable Uniform Bucket Level Access | source code | |
Storage Set File Metadata. | source code | |
Generate Encryption Key | source code | |
Generate Signed Url | source code | |
Generate V4 Read Signed Url | source code | |
Generate V4 Signed Policy | source code | |
Generate V4 Upload Signed Url | source code | |
Get Default Event Based Hold | source code | |
Get Metadata | source code | |
Get Metadata Notifications | source code | |
Get Requester Pays Status | source code | |
Get Retention Policy | source code | |
Get Uniform Bucket Level Access | source code | |
Activate HMAC SA Key. | source code | |
Create HMAC SA Key. | source code | |
Deactivate HMAC SA Key. | source code | |
Delete HMAC SA Key. | source code | |
Get HMAC SA Key Metadata. | source code | |
List HMAC SA Keys Metadata. | source code | |
List Buckets | source code | |
List Files | source code | |
List Files By Prefix | source code | |
List Notifications | source code | |
Lock Retention Policy | source code | |
Make Public | source code | |
Move File | source code | |
Notifications | source code | |
Print Bucket Acl | source code | |
Print Bucket Acl For User | source code | |
Print File Acl | source code | |
Print File Acl For User | source code | |
Quickstart | source code | |
Release Event Based Hold | source code | |
Release Temporary Hold | source code | |
Remove Bucket Conditional Binding | source code | |
Remove Bucket Default Owner | source code | |
Remove Bucket Iam Member | source code | |
Remove Bucket Owner Acl | source code | |
Remove File Owner Acl | source code | |
Remove Retention Policy | source code | |
Rotate Encryption Key | source code | |
Set Event Based Hold | source code | |
Set Retention Policy | source code | |
Set Temporaryd Hold | source code | |
Upload a directory to a bucket. | source code | |
Upload Encrypted File | source code | |
Upload File | source code | |
Upload File With Kms Key | source code | |
View Bucket Iam Members | source code |
The Google Cloud Storage Node.js Client API Reference documentation also contains samples.
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.
Client libraries targetting some end-of-life versions of Node.js are available, and
can be installed via npm dist-tags.
The dist-tags follow the naming convention legacy-(version)
.
Legacy Node.js versions are supported as a best effort:
- Legacy versions will not be tested in continuous integration.
- Some security patches may not be able to be backported.
- Dependencies will not be kept up-to-date, and features will not be backported.
legacy-8
: install client libraries from this dist-tag for versions compatible with Node.js 8.
This library follows Semantic Versioning.
This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.
More Information: Google Cloud Platform Launch Stages
Contributions welcome! See the Contributing Guide.
Please note that this README.md
, the samples/README.md
,
and a variety of configuration files in this repository (including .nycrc
and tsconfig.json
)
are generated from a central template. To edit one of these files, make an edit
to its template in this
directory.
Apache Version 2.0
See LICENSE