From 0b1b52c95730e23ced162a4878a70b21310d3306 Mon Sep 17 00:00:00 2001 From: Hanzhen Yi Date: Wed, 30 May 2018 13:05:52 -0700 Subject: [PATCH] Add port to storage upload url --- .../java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java index 1ce683e7aab4..9fcf24ccb628 100644 --- a/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java +++ b/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/spi/v1/HttpStorageRpc.java @@ -717,8 +717,10 @@ public String open(StorageObject object, Map options) { GenericUrl url = req.buildHttpRequest().getUrl(); String scheme = url.getScheme(); String host = url.getHost(); + int port = url.getPort(); + port = port < 0 ? port : url.toURL().getDefaultPort(); String path = "/upload" + url.getRawPath(); - url = new GenericUrl(scheme + "://" + host + path); + url = new GenericUrl(scheme + "://" + host + ":" + port + path); url.set("uploadType", "resumable"); url.set("name", object.getName()); for (Option option : options.keySet()) {