From b5859cab3fe8af7e8053f5160bac8b4c1a44eb01 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Mon, 19 Sep 2016 13:40:52 -0700 Subject: [PATCH] vision: Got empty response when requests are gzipped. This adds a workaround to the remaining samples for an issue where requests over a certain size will "succeed" but return an empty response from the vision API when gzipped. The workaround is to disable gzip compression. Most images should be in compressed formats anyway, so it's not like we are saving much bandwidth with it. --- .../java/com/google/cloud/vision/samples/label/LabelApp.java | 2 +- .../cloud/vision/samples/landmarkdetection/DetectLandmark.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java b/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java index cf5e0bf90c4..74d8dfd49a9 100644 --- a/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java +++ b/vision/label/src/main/java/com/google/cloud/vision/samples/label/LabelApp.java @@ -129,7 +129,7 @@ public List labelImage(Path path, int maxResults) throws IOExc vision.images() .annotate(new BatchAnnotateImagesRequest().setRequests(ImmutableList.of(request))); // Due to a bug: requests to Vision API containing large images fail when GZipped. - // annotate.setDisableGZipContent(true); + annotate.setDisableGZipContent(true); // [END construct_request] // [START parse_response] diff --git a/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java b/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java index 289e38c7380..e1df29092d6 100644 --- a/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java +++ b/vision/landmark-detection/src/main/java/com/google/cloud/vision/samples/landmarkdetection/DetectLandmark.java @@ -115,6 +115,8 @@ public List identifyLandmark(String uri, int maxResults) throw Vision.Images.Annotate annotate = vision.images() .annotate(new BatchAnnotateImagesRequest().setRequests(ImmutableList.of(request))); + // Due to a bug: requests to Vision API containing large images fail when GZipped. + annotate.setDisableGZipContent(true); BatchAnnotateImagesResponse batchResponse = annotate.execute(); assert batchResponse.getResponses().size() == 1;