Skip to content

Commit 1bf5e7e

Browse files
andrey-qlogicchingor13
authored andcommitted
---
yaml --- r: 11513 b: refs/heads/autosynth-container c: 97b1efc h: refs/heads/master i: 11511: b293c11
1 parent ab8ff15 commit 1bf5e7e

5 files changed

Lines changed: 43 additions & 1 deletion

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ refs/tags/v0.65.0: 10939381ffe0b8da32db4fe3087c86e3aa7f3e55
113113
refs/tags/v0.66.0: ed6a3f57cbdaa20339a1995f7d7d53b172a5b8ef
114114
refs/tags/v0.67.0: 30b56f02092efc6f3c3667650ea8b8825003e0b7
115115
refs/heads/autosynth-compute: fa508ebab5b6a1db14949441c8de868cefbcf1a6
116-
refs/heads/autosynth-container: 940999d7a50b1d006b5869c1bcd1eea7aaec4c71
116+
refs/heads/autosynth-container: 97b1efc4cd24639d84cab1de244bc03fb23e2a3e
117117
refs/heads/autosynth-dataproc: 26b0bac0a5713f50e2f43d45fb3583391ffb185a
118118
refs/heads/autosynth-monitoring: 2cb98362409ff765ae26032b64bc84191cdc6dda
119119
refs/heads/autosynth-pubsub: 957d781d8d170777a53a948cd958e368a96eacd5

branches/autosynth-container/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ public static BlobTargetOption metagenerationNotMatch() {
346346
return new BlobTargetOption(StorageRpc.Option.IF_METAGENERATION_NOT_MATCH);
347347
}
348348

349+
/**
350+
* Returns an option for blob's data disabledGzipContent. If this option is used, the request
351+
* will create a blob with disableGzipContent; at present, this is only for upload.
352+
*/
353+
public static BlobTargetOption disableGzipContent() {
354+
return new BlobTargetOption(StorageRpc.Option.IF_DISABLE_GZIP_CONTENT, true);
355+
}
356+
349357
/**
350358
* Returns an option to set a customer-supplied AES256 key for server-side encryption of the
351359
* blob.

branches/autosynth-container/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ public StorageObject create(
287287
storageObject,
288288
new InputStreamContent(storageObject.getContentType(), content));
289289
insert.getMediaHttpUploader().setDirectUploadEnabled(true);
290+
Boolean disableGzipContent = Option.IF_DISABLE_GZIP_CONTENT.getBoolean(options);
291+
if (disableGzipContent != null)
292+
insert.getMediaHttpUploader().setDisableGZipContent(disableGzipContent);
290293
setEncryptionHeaders(insert.getRequestHeaders(), ENCRYPTION_KEY_PREFIX, options);
291294
return insert
292295
.setProjection(DEFAULT_PROJECTION)

branches/autosynth-container/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/StorageRpc.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum Option {
4848
IF_SOURCE_METAGENERATION_NOT_MATCH("ifSourceMetagenerationNotMatch"),
4949
IF_SOURCE_GENERATION_MATCH("ifSourceGenerationMatch"),
5050
IF_SOURCE_GENERATION_NOT_MATCH("ifSourceGenerationNotMatch"),
51+
IF_DISABLE_GZIP_CONTENT("disableGzipContent"),
5152
PREFIX("prefix"),
5253
MAX_RESULTS("maxResults"),
5354
PAGE_TOKEN("pageToken"),

branches/autosynth-container/google-cloud-clients/google-cloud-storage/src/test/java/com/google/cloud/storage/StorageImplTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public class StorageImplTest {
154154
private static final BlobTargetOption BLOB_TARGET_GENERATION = BlobTargetOption.generationMatch();
155155
private static final BlobTargetOption BLOB_TARGET_METAGENERATION =
156156
BlobTargetOption.metagenerationMatch();
157+
private static final BlobTargetOption BLOB_TARGET_DISABLE_GZIP_CONTENT =
158+
BlobTargetOption.disableGzipContent();
157159
private static final BlobTargetOption BLOB_TARGET_NOT_EXIST = BlobTargetOption.doesNotExist();
158160
private static final BlobTargetOption BLOB_TARGET_PREDEFINED_ACL =
159161
BlobTargetOption.predefinedAcl(Storage.PredefinedAcl.PRIVATE);
@@ -162,6 +164,8 @@ public class StorageImplTest {
162164
StorageRpc.Option.IF_METAGENERATION_MATCH, BLOB_INFO1.getMetageneration(),
163165
StorageRpc.Option.IF_GENERATION_MATCH, 0L,
164166
StorageRpc.Option.PREDEFINED_ACL, BUCKET_TARGET_PREDEFINED_ACL.getValue());
167+
private static final Map<StorageRpc.Option, ?> BLOB_TARGET_OPTIONS_CREATE_DISABLE_GZIP_CONTENT =
168+
ImmutableMap.of(StorageRpc.Option.IF_DISABLE_GZIP_CONTENT, true);
165169
private static final Map<StorageRpc.Option, ?> BLOB_TARGET_OPTIONS_UPDATE =
166170
ImmutableMap.of(
167171
StorageRpc.Option.IF_METAGENERATION_MATCH, BLOB_INFO1.getMetageneration(),
@@ -545,6 +549,32 @@ public void testCreateBlobWithOptions() throws IOException {
545549
assertEquals(-1, byteStream.read(streamBytes));
546550
}
547551

552+
@Test
553+
public void testCreateBlobWithDisabledGzipContent() throws IOException {
554+
Capture<ByteArrayInputStream> capturedStream = Capture.newInstance();
555+
EasyMock.expect(
556+
storageRpcMock.create(
557+
EasyMock.eq(
558+
BLOB_INFO1
559+
.toBuilder()
560+
.setMd5(CONTENT_MD5)
561+
.setCrc32c(CONTENT_CRC32C)
562+
.build()
563+
.toPb()),
564+
EasyMock.capture(capturedStream),
565+
EasyMock.eq(BLOB_TARGET_OPTIONS_CREATE_DISABLE_GZIP_CONTENT)))
566+
.andReturn(BLOB_INFO1.toPb());
567+
EasyMock.replay(storageRpcMock);
568+
initializeService();
569+
Blob blob = storage.create(BLOB_INFO1, BLOB_CONTENT, BLOB_TARGET_DISABLE_GZIP_CONTENT);
570+
assertEquals(expectedBlob1, blob);
571+
ByteArrayInputStream byteStream = capturedStream.getValue();
572+
byte[] streamBytes = new byte[BLOB_CONTENT.length];
573+
assertEquals(BLOB_CONTENT.length, byteStream.read(streamBytes));
574+
assertArrayEquals(BLOB_CONTENT, streamBytes);
575+
assertEquals(-1, byteStream.read(streamBytes));
576+
}
577+
548578
@Test
549579
public void testCreateBlobWithEncryptionKey() throws IOException {
550580
Capture<ByteArrayInputStream> capturedStream = Capture.newInstance();

0 commit comments

Comments
 (0)