From 2b9e9a2c04fcb8b3b93d3207f547f6f95bf681e9 Mon Sep 17 00:00:00 2001 From: andrey-qlogic Date: Wed, 28 Nov 2018 09:37:40 +0000 Subject: [PATCH 1/5] 3822: Added contentOffset to MediaHttpUploader and AbstractGoogleClientRequest. --- .../googleapis/media/MediaHttpUploader.java | 29 +++++++++++++++++++ .../services/AbstractGoogleClientRequest.java | 18 +++++++++++- .../media/MediaHttpUploaderTest.java | 2 +- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/media/MediaHttpUploader.java b/google-api-client/src/main/java/com/google/api/client/googleapis/media/MediaHttpUploader.java index 7b8e8da40..97a96f8cc 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/media/MediaHttpUploader.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/media/MediaHttpUploader.java @@ -260,6 +260,15 @@ public enum UploadState { */ private boolean disableGZipContent; + /** + * Content offset for this uploader. + * + *

+ * The default value is {@code -1}. + *

+ */ + private long contentOffset = -1; + /** Sleeper. **/ Sleeper sleeper = Sleeper.DEFAULT; @@ -351,6 +360,7 @@ private HttpResponse directUpload(GenericUrl initiationRequestUrl) throws IOExce initiationRequestUrl.put("uploadType", "multipart"); } else { initiationRequestUrl.put("uploadType", "media"); + initiationRequestUrl.put("contentOffset", String.valueOf(contentOffset)); } HttpRequest request = requestFactory.buildRequest(initiationRequestMethod, initiationRequestUrl, content); @@ -850,6 +860,25 @@ public MediaHttpUploader setDisableGZipContent(boolean disableGZipContent) { return this; } + /** + * Returns content Offset for the uploader. + * + * @since 1.27 + */ + public long getContentOffset() { + return contentOffset; + } + + /** + * Set content Offset for the uploader. + * + * @since 1.27 + */ + public MediaHttpUploader setContentOffset(long contentOffset) { + this.contentOffset = contentOffset; + return this; + } + /** * Returns the sleeper. * diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java index 5a23f315c..387ced576 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java @@ -94,6 +94,9 @@ public abstract class AbstractGoogleClientRequest extends GenericData { /** Whether to disable GZip compression of HTTP content. */ private boolean disableGZipContent; + /** Content offset long the request for media uploader. */ + private long contentOffset = -1; + /** Response class to parse into. */ private Class responseClass; @@ -223,6 +226,17 @@ public AbstractGoogleClientRequest setDisableGZipContent(boolean disableGZipC return this; } + /** Gets content offset. */ + public long getContentOffset() { + return contentOffset; + } + + /** Sets content offset. */ + public AbstractGoogleClientRequest setContentOffset(long contentOffset) { + this.contentOffset = contentOffset; + return this; + } + /** Returns the HTTP method. */ public final String getRequestMethod() { return requestMethod; @@ -505,7 +519,9 @@ private HttpResponse executeUnparsed(boolean usingHead) throws IOException { boolean throwExceptionOnExecuteError = httpRequest.getThrowExceptionOnExecuteError(); response = uploader.setInitiationHeaders(requestHeaders) - .setDisableGZipContent(disableGZipContent).upload(httpRequestUrl); + .setDisableGZipContent(disableGZipContent) + .setContentOffset(contentOffset) + .upload(httpRequestUrl); response.getRequest().setParser(getAbstractGoogleClient().getObjectParser()); // process any error if (throwExceptionOnExecuteError && !response.isSuccessStatusCode()) { diff --git a/google-api-client/src/test/java/com/google/api/client/googleapis/media/MediaHttpUploaderTest.java b/google-api-client/src/test/java/com/google/api/client/googleapis/media/MediaHttpUploaderTest.java index 6feff227b..c92938452 100644 --- a/google-api-client/src/test/java/com/google/api/client/googleapis/media/MediaHttpUploaderTest.java +++ b/google-api-client/src/test/java/com/google/api/client/googleapis/media/MediaHttpUploaderTest.java @@ -57,7 +57,7 @@ public class MediaHttpUploaderTest extends TestCase { private static final String TEST_RESUMABLE_REQUEST_URL = "http://www.test.com/request/url?uploadType=resumable"; private static final String TEST_DIRECT_REQUEST_URL = - "http://www.test.com/request/url?uploadType=media"; + "http://www.test.com/request/url?uploadType=media&contentOffset=-1"; private static final String TEST_MULTIPART_REQUEST_URL = "http://www.test.com/request/url?uploadType=multipart"; private static final String TEST_UPLOAD_URL = "http://www.test.com/media/upload/location"; From 9dfdca363d156013ca92e69c44059c668aab3708 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 6 Dec 2018 08:35:09 -0800 Subject: [PATCH 2/5] Update guava to 26.0-android (#1218) --- .../google-api-client-android-dependencies.html | 8 ++++---- ...google-api-client-appengine-dependencies.html | 8 ++++---- .../google-api-client-dependencies.html | 8 ++++---- .../google-api-client-gson-dependencies.html | 8 ++++---- .../google-api-client-jackson2-dependencies.html | 8 ++++---- .../google-api-client-java6-dependencies.html | 8 ++++---- .../google-api-client-protobuf-dependencies.html | 8 ++++---- .../google-api-client-servlet-dependencies.html | 8 ++++---- .../google-api-client-xml-dependencies.html | 8 ++++---- ...oogle-http-client-appengine-dependencies.html | 8 ++++---- .../google-http-client-dependencies.html | 16 ++++++++-------- .../google-http-client-gson-dependencies.html | 8 ++++---- .../google-http-client-jackson-dependencies.html | 8 ++++---- ...google-http-client-jackson2-dependencies.html | 8 ++++---- .../google-http-client-jdo-dependencies.html | 8 ++++---- .../google-http-client-xml-dependencies.html | 8 ++++---- ...ogle-oauth-client-appengine-dependencies.html | 8 ++++---- .../google-oauth-client-dependencies.html | 8 ++++---- .../google-oauth-client-java6-dependencies.html | 8 ++++---- ...google-oauth-client-servlet-dependencies.html | 8 ++++---- google-api-client-jackson2/pom.xml | 2 +- pom.xml | 2 +- 22 files changed, 86 insertions(+), 86 deletions(-) diff --git a/google-api-client-assembly/dependencies/google-api-client-android-dependencies.html b/google-api-client-assembly/dependencies/google-api-client-android-dependencies.html index e40e3aa77..acd9a36ce 100644 --- a/google-api-client-assembly/dependencies/google-api-client-android-dependencies.html +++ b/google-api-client-assembly/dependencies/google-api-client-android-dependencies.html @@ -122,7 +122,7 @@

compile

com.google.guava guava -20.0 +26.0-android jar The Apache Software License, Version 2.0 @@ -380,7 +380,7 @@

Dependency Tree

Description: Core Jackson processing abstractions (aka Streaming API), implementation for JSON

URL: https://github.com/FasterXML/jackson-core

Project License: The Apache Software License, Version 2.0

-
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (compile) Information
  • com.google.guava:guava:jar:26.0-android (compile) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (provided) Information
  • com.google.guava:guava:jar:26.0-android (provided) Information
  • -
  • com.google.guava:guava-testlib:jar:20.0 (test) Information
  • com.google.guava:guava-testlib:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information
  • -
  • com.google.guava:guava:jar:20.0 (test) Information
  • com.google.guava:guava:jar:26.0-android (test) Information