diff --git a/README.md b/README.md index 2394ea3bee..6d2bb70810 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.30.0') +implementation platform('com.google.cloud:libraries-bom:26.31.0') implementation 'com.google.cloud:google-cloud-storage' ``` diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java index f21860e7f7..9d4873e2b4 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/HttpStorageOptions.java @@ -323,6 +323,17 @@ public HttpStorageRpcFactory() {} public ServiceRpc create(StorageOptions options) { if (options instanceof HttpStorageOptions) { HttpStorageOptions httpStorageOptions = (HttpStorageOptions) options; + // todo: In the future, this step will be done automatically, and the getResolvedApiaryHost + // helper method will + // be removed. When that happens, delete the following block. + // https://github.com/googleapis/google-api-java-client-services/issues/19286 + if (httpStorageOptions.getUniverseDomain() != null) { + httpStorageOptions = + httpStorageOptions + .toBuilder() + .setHost(httpStorageOptions.getResolvedApiaryHost("storage")) + .build(); + } return new HttpStorageRpc(httpStorageOptions); } else { throw new IllegalArgumentException("Only HttpStorageOptions supported"); diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java index 94b3387768..9af54fee20 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/StorageImpl.java @@ -101,7 +101,12 @@ final class StorageImpl extends BaseService implements Storage { /** Signed URLs are only supported through the GCS XML API endpoint. */ private static final String STORAGE_XML_URI_SCHEME = "https"; - private static final String STORAGE_XML_URI_HOST_NAME = "storage.googleapis.com"; + // TODO: in the future, this can be replaced by getOptions().getHost() + private final String STORAGE_XML_URI_HOST_NAME = + getOptions() + .getResolvedApiaryHost("storage") + .replaceFirst("http(s)?://", "") + .replace("/", ""); private static final int DEFAULT_BUFFER_SIZE = 15 * 1024 * 1024; private static final int MIN_BUFFER_SIZE = 256 * 1024; @@ -1048,7 +1053,8 @@ private SignatureInfo buildSignatureInfo( "host", slashlessBucketNameFromBlobInfo(blobInfo) + "." + getBaseStorageHostName(optionMap)); } else if (optionMap.containsKey(SignUrlOption.Option.HOST_NAME) - || optionMap.containsKey(SignUrlOption.Option.BUCKET_BOUND_HOST_NAME)) { + || optionMap.containsKey(SignUrlOption.Option.BUCKET_BOUND_HOST_NAME) + || getOptions().getUniverseDomain() != null) { extHeadersBuilder.put("host", getBaseStorageHostName(optionMap)); } } @@ -1576,7 +1582,16 @@ public boolean deleteNotification(final String bucket, final String notification @Override public HttpStorageOptions getOptions() { - return (HttpStorageOptions) super.getOptions(); + HttpStorageOptions options = (HttpStorageOptions) super.getOptions(); + /** + * TODO: In the future, this should happen automatically, and this block will be deleted + * https://github.com/googleapis/google-api-java-client-services/issues/19286 + */ + if (options.getUniverseDomain() != null) { + + return options.toBuilder().setHost(options.getResolvedApiaryHost("storage")).build(); + } + return options; } private Blob internalGetBlob(BlobId blob, Map optionsMap) {