Skip to content

Commit 4ba9dda

Browse files
committed
Move storage samples.
1 parent 7cd93ef commit 4ba9dda

24 files changed

+123
-2564
lines changed

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ deployment:
109109
- node scripts/build "resource"
110110
- node scripts/build "spanner"
111111
- node scripts/build "speech"
112-
- node scripts/build "storage"
112+
- node scripts/build "storage-transfer"
113113
- node scripts/build "trace"
114114
- node scripts/build "translate"
115115
# TODO: This build times out. Does video need more than 10 minutes?

scripts/clean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ const args = process.argv.slice(2);
2222
if (!args.length || args[0] === 'coverage') {
2323
rm('-rf', 'coverage');
2424
} else if (args[0] === 'buckets') {
25-
const NAME_REG_EXP = /^nodejs-docs-samples-test-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/;
26-
const NAME_REG_EXP_2 = /^docs-samples-gae-test-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/;
25+
const NAME_REG_EXP = /^docs-samples-gae-test-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/;
2726

2827
storage
2928
.getBuckets()
3029
.then(([buckets]) => {
3130
let promise = Promise.resolve();
3231

3332
buckets
34-
.filter((bucket) => NAME_REG_EXP.test(bucket.name) || NAME_REG_EXP_2.test(bucket.name))
33+
.filter((bucket) => NAME_REG_EXP.test(bucket.name))
3534
.forEach((bucket) => {
3635
promise = promise.then(() => {
3736
return bucket.deleteFiles()

storage-transfer/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
2+
3+
# Google Cloud Storage Transfer API Node.js Samples
4+
5+
[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-storage-transfer.svg)]()
6+
7+
## Table of Contents
8+
9+
* [Setup](#setup)
10+
* [Samples](#samples)
11+
* [Storage Transfer API](#storage-transfer-api)
12+
* [Running the tests](#running-the-tests)
13+
14+
## Setup
15+
16+
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
17+
1. Install dependencies:
18+
19+
With **npm**:
20+
21+
npm install
22+
23+
With **yarn**:
24+
25+
yarn install
26+
27+
[prereq]: ../README.md#prerequisites
28+
[run]: ../README.md#how-to-run-a-sample
29+
30+
## Samples
31+
32+
### Storage Transfer API
33+
34+
View the [documentation][transfer_0_docs] or the [source code][transfer_0_code].
35+
36+
__Usage:__ `node transfer.js --help`
37+
38+
```
39+
Commands:
40+
jobs <cmd> [args] Run a job command.
41+
operations <cmd> [args] Run an operation command.
42+
43+
Options:
44+
--help Show help [boolean]
45+
46+
Examples:
47+
node transfer.js jobs --help Show job commands.
48+
node transfer.js operations --help Show operations commands.
49+
50+
For more information, see https://cloud.google.com/storage/transfer
51+
```
52+
53+
[transfer_0_docs]: https://cloud.google.com/storage/transfer
54+
[transfer_0_code]: transfer.js
55+
56+
## Running the tests
57+
58+
1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.
59+
60+
1. Run the tests:
61+
62+
With **npm**:
63+
64+
npm test
65+
66+
With **yarn**:
67+
68+
yarn test

storage-transfer/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "nodejs-docs-samples-storage-transfer",
3+
"version": "0.0.1",
4+
"private": true,
5+
"license": "Apache-2.0",
6+
"author": "Google Inc.",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
10+
},
11+
"engines": {
12+
"node": ">=4"
13+
},
14+
"scripts": {
15+
"lint": "samples lint",
16+
"pretest": "npm run lint",
17+
"unit-test": "samples test run --cmd ava -- -T 20s --verbose test/*.test.js",
18+
"system-test": "samples test run --cmd ava -- -T 20s --verbose system-test/*.test.js",
19+
"test": "npm run unit-test && npm run system-test"
20+
},
21+
"dependencies": {
22+
"googleapis": "21.3.0",
23+
"moment": "2.18.1",
24+
"safe-buffer": "5.1.1",
25+
"yargs": "9.0.1"
26+
},
27+
"devDependencies": {
28+
"@google-cloud/nodejs-repo-tools": "1.4.17",
29+
"ava": "0.22.0",
30+
"proxyquire": "1.8.0",
31+
"sinon": "3.3.0",
32+
"uuid": "3.1.0"
33+
},
34+
"cloud-repo-tools": {
35+
"requiresKeyFile": true,
36+
"requiresProjectId": true,
37+
"product": "storage",
38+
"samples": [
39+
{
40+
"id": "transfer",
41+
"name": "Storage Transfer API",
42+
"file": "transfer.js",
43+
"docs_link": "https://cloud.google.com/storage/transfer",
44+
"usage": "node transfer.js --help"
45+
}
46+
]
47+
}
48+
}
File renamed without changes.

storage/README.md

Lines changed: 4 additions & 247 deletions
Original file line numberDiff line numberDiff line change
@@ -1,248 +1,5 @@
1-
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
1+
Samples for the [Google Cloud Storage Node.js Client][client] have moved to
2+
[github.com/googleapis/nodejs-storage: samples/][samples].
23

3-
# Google Cloud Storage Node.js Samples
4-
5-
[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-storage.svg)]()
6-
7-
[Cloud Storage](https://cloud.google.com/storage/docs) 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.
8-
9-
## Table of Contents
10-
11-
* [Setup](#setup)
12-
* [Samples](#samples)
13-
* [ACL (Access Control Lists)](#acl-access-control-lists)
14-
* [Buckets](#buckets)
15-
* [Encryption](#encryption)
16-
* [Files](#files)
17-
* [Storage Transfer API](#storage-transfer-api)
18-
* [Requester Pays samples](#requester-pays-samples)
19-
* [Running the tests](#running-the-tests)
20-
21-
## Setup
22-
23-
1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
24-
1. Install dependencies:
25-
26-
With **npm**:
27-
28-
npm install
29-
30-
With **yarn**:
31-
32-
yarn install
33-
34-
[prereq]: ../README.md#prerequisites
35-
[run]: ../README.md#how-to-run-a-sample
36-
37-
## Samples
38-
39-
### ACL (Access Control Lists)
40-
41-
View the [documentation][acl_0_docs] or the [source code][acl_0_code].
42-
43-
__Usage:__ `node acl.js --help`
44-
45-
```
46-
Commands:
47-
print-bucket-acl <bucketName> Prints the ACL for a bucket.
48-
print-bucket-acl-for-user <bucketName> <userEmail> Prints a user's ACL for a bucket.
49-
add-bucket-owner <bucketName> <userEmail> Adds a user as an owner of a bucket.
50-
remove-bucket-owner <bucketName> <userEmail> Removes a user from the ACL of a bucket.
51-
add-bucket-default-owner <bucketName> <userEmail> Adds a user as an owner in the default ACL of a bucket.
52-
remove-bucket-default-owner <bucketName> <userEmail> Removes a user from the default ACL of a bucket.
53-
print-file-acl <bucketName> <fileName> Prints the ACL for a file.
54-
print-file-acl-for-user <bucketName> <fileName> <userEmail> Prints a user's ACL for a file.
55-
add-file-owner <bucketName> <fileName> <userEmail> Adds a user as an owner of a file.
56-
remove-file-owner <bucketName> <fileName> <userEmail> Removes a user from the ACL of a file.
57-
58-
Options:
59-
--help Show help [boolean]
60-
61-
Examples:
62-
node acl.js print-bucket-acl my-bucket
63-
node acl.js print-bucket-acl-for-user my-bucket [email protected]
64-
node acl.js add-bucket-owner my-bucket [email protected]
65-
node acl.js remove-bucket-owner my-bucket [email protected]
66-
node acl.js add-bucket-default-owner my-bucket [email protected]
67-
node acl.js remove-bucket-default-owner my-bucket [email protected]
68-
node acl.js print-file-acl my-bucket file.txt
69-
node acl.js print-file-acl-for-user my-bucket file.txt [email protected]
70-
node acl.js add-file-owner my-bucket file.txt [email protected]
71-
node acl.js remove-file-owner my-bucket file.txt [email protected]
72-
73-
For more information, see https://cloud.google.com/storage/docs/access-control/create-manage-lists
74-
```
75-
76-
[acl_0_docs]: https://cloud.google.com/storage/docs/access-control/create-manage-lists
77-
[acl_0_code]: acl.js
78-
79-
### Buckets
80-
81-
View the [documentation][buckets_1_docs] or the [source code][buckets_1_code].
82-
83-
__Usage:__ `node buckets.js --help`
84-
85-
```
86-
Commands:
87-
create <bucket> Creates a new bucket.
88-
list Lists all buckets in the current project.
89-
delete <bucket> Deletes a bucket.
90-
91-
Options:
92-
--help Show help [boolean]
93-
94-
Examples:
95-
node buckets.js create my-bucket Creates a new bucket named "my-bucket".
96-
node buckets.js list Lists all buckets in the current project.
97-
node buckets.js delete my-bucket Deletes a bucket named "my-bucket".
98-
99-
For more information, see https://cloud.google.com/storage/docs
100-
```
101-
102-
[buckets_1_docs]: https://cloud.google.com/storage/docs
103-
[buckets_1_code]: buckets.js
104-
105-
### Encryption
106-
107-
View the [documentation][encryption_2_docs] or the [source code][encryption_2_code].
108-
109-
__Usage:__ `node encryption.js --help`
110-
111-
```
112-
Commands:
113-
generate-encryption-key Generate a sample encryption key.
114-
upload <bucketName> <srcFilename> <destFilename> <key> Encrypts and uploads a file.
115-
download <bucketName> <srcFilename> <destFilename> <key> Decrypts and downloads a file.
116-
rotate <bucketName> <fileName> <oldkey> <newKey> Rotates encryption keys for a file.
117-
118-
Options:
119-
--help Show help [boolean]
120-
121-
Examples:
122-
node encryption.js generate-encryption-key Generate a sample encryption key.
123-
node encryption.js upload my-bucket ./resources/test.txt Encrypts and uploads "resources/test.txt" to
124-
file_encrypted.txt QxhqaZEqBGVTW55HhQw9Q= "gs://my-bucket/file_encrypted.txt".
125-
node encryption.js download my-bucket file_encrypted.txt Decrypts and downloads
126-
./file.txt QxhqaZEqBGVTW55HhQw9Q= "gs://my-bucket/file_encrypted.txt" to "./file.txt".
127-
node encryption.js rotate my-bucket file_encrypted.txt Rotates encryption keys for
128-
QxhqaZEqBGVTW55HhQw9Q= SxafpsdfSDFS89sds9Q= "gs://my-bucket/file_encrypted.txt".
129-
130-
For more information, see https://cloud.google.com/storage/docs
131-
```
132-
133-
[encryption_2_docs]: https://cloud.google.com/storage/docs
134-
[encryption_2_code]: encryption.js
135-
136-
### Files
137-
138-
View the [documentation][files_3_docs] or the [source code][files_3_code].
139-
140-
__Usage:__ `node files.js --help`
141-
142-
```
143-
Commands:
144-
list <bucketName> [prefix] [delimiter] Lists files in a bucket, optionally filtering by a
145-
prefix.
146-
upload <bucketName> <srcFileName> Uploads a local file to a bucket.
147-
download <bucketName> <srcFileName> <destFileName> Downloads a file from a bucket.
148-
delete <bucketName> <fileName> Deletes a file from a bucket.
149-
get-metadata <bucketName> <fileName> Gets the metadata for a file.
150-
make-public <bucketName> <fileName> Makes a file public.
151-
generate-signed-url <bucketName> <fileName> Generates a signed URL for a file.
152-
move <bucketName> <srcFileName> <destFileName> Moves a file to a new location within the same bucket,
153-
i.e. rename the file.
154-
copy <srcBucketName> <srcFileName> <destBucketName> Copies a file in a bucket to another bucket.
155-
<destFileName>
156-
157-
Options:
158-
--help Show help [boolean]
159-
160-
Examples:
161-
node files.js list my-bucket Lists files in "my-bucket".
162-
node files.js list my-bucket public/ Lists files in "my-bucket" filtered by prefix "public/".
163-
node files.js upload my-bucket ./file.txt Uploads "./file.txt" to "my-bucket".
164-
node files.js download my-bucket file.txt ./file.txt Downloads "gs://my-bucket/file.txt" to "./file.txt".
165-
node files.js delete my-bucket file.txt Deletes "gs://my-bucket/file.txt".
166-
node files.js get-metadata my-bucket file.txt Gets the metadata for "gs://my-bucket/file.txt".
167-
node files.js make-public my-bucket file.txt Makes "gs://my-bucket/file.txt" public.
168-
node files.js move my-bucket file.txt file2.txt Renames "gs://my-bucket/file.txt" to
169-
"gs://my-bucket/file2.txt".
170-
node files.js copy my-bucket file.txt my-other-bucket Copies "gs://my-bucket/file.txt" to
171-
file.txt "gs://my-other-bucket/file.txt".
172-
173-
For more information, see https://cloud.google.com/storage/docs
174-
```
175-
176-
[files_3_docs]: https://cloud.google.com/storage/docs
177-
[files_3_code]: files.js
178-
179-
### Storage Transfer API
180-
181-
View the [documentation][transfer_4_docs] or the [source code][transfer_4_code].
182-
183-
__Usage:__ `node transfer.js --help`
184-
185-
```
186-
Commands:
187-
jobs <cmd> [args] Run a job command.
188-
operations <cmd> [args] Run an operation command.
189-
190-
Options:
191-
--help Show help [boolean]
192-
193-
Examples:
194-
node transfer.js jobs --help Show job commands.
195-
node transfer.js operations --help Show operations commands.
196-
197-
For more information, see https://cloud.google.com/storage/transfer
198-
```
199-
200-
[transfer_4_docs]: https://cloud.google.com/storage/transfer
201-
[transfer_4_code]: transfer.js
202-
203-
### Requester Pays samples
204-
205-
View the [documentation][requesterPays_5_docs] or the [source code][requesterPays_5_code].
206-
207-
__Usage:__ `node requesterPays.js --help`
208-
209-
```
210-
Commands:
211-
enable <bucket> Enables requester-pays requests on a bucket.
212-
disable <bucket> Disables requester-pays requests on a bucket.
213-
get-status <bucket> Determines whether requester-pays requests are enabled on a
214-
bucket.
215-
download <bucketName> <srcFileName> <destFileName> Downloads a file from a bucket using requester-pays requests.
216-
217-
Options:
218-
--help Show help [boolean]
219-
220-
Examples:
221-
node requesterPays.js enable my-bucket Enables requester-pays requests on a bucket named
222-
"my-bucket".
223-
node requesterPays.js disable my-bucket Disables requester-pays requests on a bucket named
224-
"my-bucket".
225-
node requesterPays.js get-status my-bucket Determines whether requester-pays requests are enabled
226-
for a bucket named "my-bucket".
227-
node requesterPays.js download my-bucket file.txt ./file.txt Downloads "gs://my-bucket/file.txt" to "./file.txt"
228-
using requester-pays requests.
229-
230-
For more information, see https://cloud.google.com/storage/docs
231-
```
232-
233-
[requesterPays_5_docs]: https://cloud.google.com/storage/docs
234-
[requesterPays_5_code]: requesterPays.js
235-
236-
## Running the tests
237-
238-
1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.
239-
240-
1. Run the tests:
241-
242-
With **npm**:
243-
244-
npm test
245-
246-
With **yarn**:
247-
248-
yarn test
4+
[client]: https://github.com/googleapis/nodejs-storage
5+
[samples]: https://github.com/googleapis/nodejs-storage/tree/master/samples

0 commit comments

Comments
 (0)