Skip to content

Commit 661edfa

Browse files
authored
Updates for storage, translate, unittests, and video. (GoogleCloudPlatform#994)
* Updated storage/cloud-client. * Updated storage/json-api * Updated storage/storage-transfer. * Updated translate/ * Updated unittests/ * Updated video/
1 parent 5e6760e commit 661edfa

File tree

48 files changed

+248
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+248
-227
lines changed

storage/cloud-client/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Getting Started with Cloud Storage and the Google Cloud Client libraries
22

3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=storage/cloud-client/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
36
[Google Cloud Storage][storage] is unified object storage for developers and enterprises, from live
47
data serving to data analytics/ML to data archival.
58
These sample Java applications demonstrate how to access the Cloud Storage API using

storage/cloud-client/pom.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
<artifactId>storage-google-cloud-samples</artifactId>
2020
<packaging>jar</packaging>
2121

22-
<!-- Parent defines config for testing & linting. -->
22+
<!--
23+
The parent pom defines common style checks and testing strategies for our samples.
24+
Removing or replacing it should not affect the execution of the samples in anyway.
25+
-->
2326
<parent>
24-
<artifactId>doc-samples</artifactId>
25-
<groupId>com.google.cloud</groupId>
26-
<version>1.0.0</version>
27-
<relativePath>../..</relativePath>
27+
<groupId>com.google.cloud.samples</groupId>
28+
<artifactId>shared-configuration</artifactId>
29+
<version>1.0.8</version>
2830
</parent>
2931

3032
<properties>

storage/cloud-client/src/main/java/com/example/storage/QuickstartSample.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/*
2-
Copyright 2016, Google, Inc.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
2+
* Copyright 2015 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616

1717
package com.example.storage;
1818

storage/cloud-client/src/test/java/com/example/storage/QuickstartSampleIT.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
/*
2-
Copyright 2016, Google, Inc.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
2+
* Copyright 2015 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616

1717
package com.example.storage;
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

2121
import com.google.cloud.storage.Storage;
2222
import com.google.cloud.storage.StorageOptions;
23+
import java.io.ByteArrayOutputStream;
24+
import java.io.PrintStream;
25+
import java.util.UUID;
2326
import org.junit.After;
2427
import org.junit.Before;
2528
import org.junit.Test;
2629
import org.junit.runner.RunWith;
2730
import org.junit.runners.JUnit4;
2831

29-
import java.io.ByteArrayOutputStream;
30-
import java.io.PrintStream;
31-
import java.util.UUID;
32-
3332
/**
3433
* Tests for quickstart sample.
3534
*/

storage/json-api/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Google Cloud Storage (GCS) and the Google Java API Client library
22

3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=storage/cloud-client/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
36
Google Cloud Storage Service features a REST-based API that allows developers to store and access arbitrarily-large objects. These sample Java applications demonstrate how to access the Google Cloud Storage JSON API using the Google Java API Client Libraries. For more information, read the [Google Cloud Storage JSON API Overview][1].
47

58
## Quickstart

storage/json-api/pom.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@
1414
limitations under the License.
1515
-->
1616
<project>
17-
<parent>
18-
<artifactId>doc-samples</artifactId>
19-
<groupId>com.google.cloud</groupId>
20-
<version>1.0.0</version>
21-
<relativePath>../..</relativePath>
22-
</parent>
23-
2417
<modelVersion>4.0.0</modelVersion>
2518
<groupId>com.google.apis-samples</groupId>
2619
<artifactId>storage-json-api</artifactId>
2720
<version>1</version>
2821

22+
<!--
23+
The parent pom defines common style checks and testing strategies for our samples.
24+
Removing or replacing it should not affect the execution of the samples in anyway.
25+
-->
26+
<parent>
27+
<groupId>com.google.cloud.samples</groupId>
28+
<artifactId>shared-configuration</artifactId>
29+
<version>1.0.8</version>
30+
</parent>
31+
2932
<properties>
3033
<maven.compiler.target>1.8</maven.compiler.target>
3134
<maven.compiler.source>1.8</maven.compiler.source>
@@ -61,6 +64,7 @@
6164
<groupId>junit</groupId>
6265
<artifactId>junit</artifactId>
6366
<scope>test</scope>
67+
<version>4.12</version>
6468
</dependency>
6569
<dependency>
6670
<groupId>com.google.truth</groupId>

storage/json-api/src/main/java/CustomerSuppliedEncryptionKeysSamples.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.api.client.http.InputStreamContent;
2020
import com.google.api.services.storage.Storage;
2121
import com.google.api.services.storage.model.RewriteResponse;
22-
2322
import java.io.IOException;
2423
import java.io.InputStream;
2524

@@ -75,17 +74,18 @@ public static InputStream downloadObject(
7574
String base64CseKey,
7675
String base64CseKeyHash)
7776
throws Exception {
78-
Storage.Objects.Get getObject = storage.objects().get(bucketName, objectName);
79-
80-
// If you're using AppEngine, turn off setDirectDownloadEnabled:
81-
// getObject.getMediaHttpDownloader().setDirectDownloadEnabled(false);
8277

83-
// Now set the CSEK headers
78+
// Set the CSEK headers
8479
final HttpHeaders httpHeaders = new HttpHeaders();
8580
httpHeaders.set("x-goog-encryption-algorithm", "AES256");
8681
httpHeaders.set("x-goog-encryption-key", base64CseKey);
8782
httpHeaders.set("x-goog-encryption-key-sha256", base64CseKeyHash);
8883

84+
Storage.Objects.Get getObject = storage.objects().get(bucketName, objectName);
85+
86+
// If you're using AppEngine, turn off setDirectDownloadEnabled:
87+
// getObject.getMediaHttpDownloader().setDirectDownloadEnabled(false);
88+
8989
getObject.setRequestHeaders(httpHeaders);
9090

9191
try {
@@ -166,10 +166,8 @@ public static void rotateKey(
166166
String newBase64Key,
167167
String newBase64KeyHash)
168168
throws Exception {
169-
Storage.Objects.Rewrite rewriteObject =
170-
storage.objects().rewrite(bucketName, objectName, bucketName, objectName, null);
171169

172-
// Now set the CSEK headers
170+
// Set the CSEK headers
173171
final HttpHeaders httpHeaders = new HttpHeaders();
174172

175173
// Specify the exiting object's current CSEK.
@@ -182,6 +180,9 @@ public static void rotateKey(
182180
httpHeaders.set("x-goog-encryption-key", newBase64Key);
183181
httpHeaders.set("x-goog-encryption-key-sha256", newBase64KeyHash);
184182

183+
Storage.Objects.Rewrite rewriteObject =
184+
storage.objects().rewrite(bucketName, objectName, bucketName, objectName, null);
185+
185186
rewriteObject.setRequestHeaders(httpHeaders);
186187

187188
try {

storage/json-api/src/main/java/StorageFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.google.api.client.json.jackson2.JacksonFactory;
2222
import com.google.api.services.storage.Storage;
2323
import com.google.api.services.storage.StorageScopes;
24-
2524
import java.io.IOException;
2625
import java.security.GeneralSecurityException;
2726
import java.util.Collection;

storage/json-api/src/main/java/StorageSample.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
//[START all]
21
/*
3-
* Copyright (c) 2014 Google Inc.
2+
* Copyright 2014 Google Inc.
43
*
5-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6-
* in compliance with the License. You may obtain a copy of the License at
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
77
*
88
* http://www.apache.org/licenses/LICENSE-2.0
99
*
10-
* Unless required by applicable law or agreed to in writing, software distributed under the License
11-
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12-
* or implied. See the License for the specific language governing permissions and limitations under
13-
* the License.
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1415
*/
1516

17+
//[START all]
18+
1619
import com.google.api.client.http.InputStreamContent;
1720
import com.google.api.services.storage.Storage;
1821
import com.google.api.services.storage.model.Bucket;
1922
import com.google.api.services.storage.model.ObjectAccessControl;
2023
import com.google.api.services.storage.model.Objects;
2124
import com.google.api.services.storage.model.StorageObject;
22-
2325
import java.io.File;
2426
import java.io.FileInputStream;
2527
import java.io.IOException;

storage/json-api/src/test/java/StorageSampleTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020

2121
import com.google.api.services.storage.model.Bucket;
2222
import com.google.api.services.storage.model.StorageObject;
23-
24-
import org.junit.Test;
25-
2623
import java.io.File;
2724
import java.nio.file.Files;
2825
import java.nio.file.Path;
2926
import java.util.List;
3027
import java.util.stream.Collectors;
28+
import org.junit.Test;
3129

3230
public class StorageSampleTest {
3331
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");

0 commit comments

Comments
 (0)