|
9 | 9 | [](https://codecov.io/gh/googleapis/nodejs-storage) |
10 | 10 |
|
11 | 11 |
|
12 | | -Cloud Storage Client Library for Node.js |
13 | 12 |
|
14 | 13 |
|
15 | | -* [Using the client library](#using-the-client-library) |
| 14 | +> Node.js idiomatic client for [Cloud Storage][product-docs]. |
| 15 | +
|
| 16 | +[Cloud Storage](https://cloud.google.com/storage/docs) allows world-wide |
| 17 | +storage and retrieval of any amount of data at any time. You can use Google |
| 18 | +Cloud Storage for a range of scenarios including serving website content, |
| 19 | +storing data for archival and disaster recovery, or distributing large data |
| 20 | +objects to users via direct download. |
| 21 | + |
| 22 | + |
| 23 | +* [Google Cloud Storage Node.js Client API Reference][client-docs] |
| 24 | +* [Google Cloud Storage Documentation][product-docs] |
| 25 | +* [github.com/googleapis/nodejs-storage](https://github.com/googleapis/nodejs-storage) |
| 26 | + |
| 27 | +Read more about the client libraries for Cloud APIs, including the older |
| 28 | +Google APIs Client Libraries, in [Client Libraries Explained][explained]. |
| 29 | + |
| 30 | +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained |
| 31 | + |
| 32 | +**Table of contents:** |
| 33 | + |
| 34 | + |
| 35 | +* [Quickstart](#quickstart) |
| 36 | + * [Before you begin](#before-you-begin) |
| 37 | + * [Installing the client library](#installing-the-client-library) |
| 38 | + * [Using the client library](#using-the-client-library) |
16 | 39 | * [Samples](#samples) |
17 | 40 | * [Versioning](#versioning) |
18 | 41 | * [Contributing](#contributing) |
19 | 42 | * [License](#license) |
20 | 43 |
|
21 | | -## Using the client library |
| 44 | +## Quickstart |
| 45 | + |
| 46 | +### Before you begin |
22 | 47 |
|
23 | 48 | 1. [Select or create a Cloud Platform project][projects]. |
24 | 49 | 1. [Enable billing for your project][billing]. |
25 | 50 | 1. [Enable the Google Cloud Storage API][enable_api]. |
26 | 51 | 1. [Set up authentication with a service account][auth] so you can access the |
27 | 52 | API from your local workstation. |
28 | 53 |
|
29 | | -1. Install the client library: |
| 54 | +### Installing the client library |
30 | 55 |
|
31 | | - npm install @google-cloud/storage |
| 56 | +```bash |
| 57 | +npm install @google-cloud/storage |
| 58 | +``` |
32 | 59 |
|
33 | 60 |
|
34 | | -1. Try an example: |
| 61 | +### Using the client library |
35 | 62 |
|
36 | 63 | ```javascript |
37 | | -async function quickstart( |
38 | | - projectId = 'YOUR_PROJECT_ID', // Your Google Cloud Platform project ID |
39 | | - bucketName = 'my-new-bucket' // The name for the new bucket |
40 | | -) { |
41 | 64 | // Imports the Google Cloud client library |
42 | 65 | const {Storage} = require('@google-cloud/storage'); |
43 | 66 |
|
44 | 67 | // Creates a client |
45 | | - const storage = new Storage({projectId}); |
| 68 | + const storage = new Storage(); |
| 69 | + |
| 70 | + /** |
| 71 | + * TODO(developer): Uncomment these variables before running the sample. |
| 72 | + */ |
| 73 | + // const bucketName = 'bucket-name'; |
| 74 | + |
| 75 | + async function createBucket() { |
| 76 | + // Creates the new bucket |
| 77 | + await storage.createBucket(bucketName); |
| 78 | + console.log(`Bucket ${bucketName} created.`); |
| 79 | + } |
46 | 80 |
|
47 | | - // Creates the new bucket |
48 | | - await storage.createBucket(bucketName); |
49 | | - console.log(`Bucket ${bucketName} created.`); |
50 | | -} |
| 81 | + createBucket(); |
51 | 82 |
|
52 | 83 | ``` |
53 | 84 |
|
@@ -103,18 +134,7 @@ Apache Version 2.0 |
103 | 134 |
|
104 | 135 | See [LICENSE](https://github.com/googleapis/nodejs-storage/blob/master/LICENSE) |
105 | 136 |
|
106 | | -## What's Next |
107 | | - |
108 | | -* [Google Cloud Storage Documentation][product-docs] |
109 | | -* [Google Cloud Storage Node.js Client API Reference][client-docs] |
110 | | -* [github.com/googleapis/nodejs-storage](https://github.com/googleapis/nodejs-storage) |
111 | | - |
112 | | -Read more about the client libraries for Cloud APIs, including the older |
113 | | -Google APIs Client Libraries, in [Client Libraries Explained][explained]. |
114 | | - |
115 | | -[explained]: https://cloud.google.com/apis/docs/client-libraries-explained |
116 | | - |
117 | | -[client-docs]: https://cloud.google.com/nodejs/docs/reference/storage/2.3.x/ |
| 137 | +[client-docs]: https://cloud.google.com/nodejs/docs/reference/storage/latest/ |
118 | 138 | [product-docs]: https://cloud.google.com/storage |
119 | 139 | [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png |
120 | 140 | [projects]: https://console.cloud.google.com/project |
|
0 commit comments