Skip to content

Commit 8c5197f

Browse files
andrey-qlogicchingor13
authored andcommitted
---
yaml --- r: 14445 b: refs/heads/autosynth-vision c: 97b1efc h: refs/heads/master i: 14443: 08e87b9
1 parent 0d1727e commit 8c5197f

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
@@ -118,7 +118,7 @@ refs/heads/autosynth-dataproc: bc74a8841bc1693d7945d991d15979df550b1fd1
118118
refs/heads/autosynth-monitoring: e67db7395a868e5f6ecc3476eb4a91c47abd4234
119119
refs/heads/autosynth-pubsub: fd363d13793a853214eb8193c922b28c54e7a6b3
120120
refs/heads/autosynth-video-intelligence: e44c9746407fe00fac42e1bb10ac50f493dd37b0
121-
refs/heads/autosynth-vision: 940999d7a50b1d006b5869c1bcd1eea7aaec4c71
121+
refs/heads/autosynth-vision: 97b1efc4cd24639d84cab1de244bc03fb23e2a3e
122122
refs/heads/spanner: 54a5e197bfe0a004e13c190427f46c3413ab572d
123123
refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b
124124
refs/tags/v0.69.0: 78f67a29e8b9c46ba01de566a2eae0fd1c03edea

branches/autosynth-vision/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-vision/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-vision/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-vision/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)