Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cc1da3c
Merge pull request #1 from googleapis/main
ShreyasSinha Sep 4, 2025
8d5aef6
squashing last two commits
ShreyasSinha Sep 17, 2025
044b483
Added url encoding
ShreyasSinha Sep 17, 2025
3c15ef2
Added md5 checksumming
ShreyasSinha Sep 17, 2025
e8eb531
Using HttpRequestFactory instead of HTTP url connection
ShreyasSinha Sep 19, 2025
4fa6113
Fixed crc32 checksum issue
ShreyasSinha Sep 25, 2025
365453b
Refactored Http requestfactory out
ShreyasSinha Sep 25, 2025
0f5eb9c
Added support for ADC credentials
ShreyasSinha Sep 29, 2025
ab9794c
Refactored XmlMapper out
ShreyasSinha Sep 29, 2025
ff37829
Removed hard coded headers
ShreyasSinha Sep 29, 2025
45c0a24
Added list API for Java XML MPU
ShreyasSinha Sep 29, 2025
bb840c0
Added list API for Java XML MPU
ShreyasSinha Sep 29, 2025
f467ab9
Added pending paramteres for CreateMultipart upload
ShreyasSinha Sep 30, 2025
9971089
Added remaining fields for CreateMultipartUpload Response
ShreyasSinha Sep 30, 2025
7672ca1
Added Complete Multipart request and response
ShreyasSinha Oct 1, 2025
d11a9d6
Added remainig parameters for CreateMultipart Upload
ShreyasSinha Oct 1, 2025
a5434fc
Add validations
ShreyasSinha Oct 1, 2025
c6bf25b
Added pending validation
ShreyasSinha Oct 1, 2025
a37072d
Added Java docs for CompleteMultipartResponse
ShreyasSinha Oct 1, 2025
b63ea92
Added java docs
ShreyasSinha Oct 1, 2025
ed63e19
md5 and crc32c added in response
ShreyasSinha Oct 3, 2025
86ea017
Added retrier implementation
ShreyasSinha Oct 3, 2025
c7f641d
Added fix for reuquest body
ShreyasSinha Oct 3, 2025
d62c3f6
Requestbody change
ShreyasSinha Oct 7, 2025
15b37b4
fixed rewindable content
ShreyasSinha Oct 10, 2025
fb23854
Removed Auth
ShreyasSinha Oct 10, 2025
aae152e
Cleaned header implementation a bit
ShreyasSinha Oct 10, 2025
43758ab
Added Unit tests
ShreyasSinha Oct 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion google-cloud-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-metrics</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.storage;

import com.google.api.client.http.ByteArrayContent;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.cloud.storage.multipartupload.model.CreateMultipartUploadRequest;
import java.io.IOException;
import java.util.Map;

public class HttpRequestManager {

private final HttpRequestFactory requestFactory;

public HttpRequestManager(HttpRequestFactory requestFactory) {
this.requestFactory = requestFactory;
}

public HttpResponse sendCreateMultipartUploadRequest(
String uri,
String contentType,
CreateMultipartUploadRequest request,
Map<String, String> extensionHeaders)
throws IOException {
HttpRequest httpRequest =
requestFactory.buildPostRequest(
new GenericUrl(uri), new ByteArrayContent(contentType, new byte[0]));
httpRequest.getHeaders().setContentType(contentType);
for (Map.Entry<String, String> entry : extensionHeaders.entrySet()) {
httpRequest.getHeaders().set(entry.getKey(), entry.getValue());
}
httpRequest.setThrowExceptionOnExecuteError(false);
return httpRequest.execute();
}

public HttpResponse sendUploadPartRequest(
String uri,
HttpContent content,
String contentType,
Map<String, String> extensionHeaders)
throws IOException {
HttpRequest httpRequest =
requestFactory.buildPutRequest(
new GenericUrl(uri), content);
httpRequest.getHeaders().setContentType(contentType);
for (Map.Entry<String, String> entry : extensionHeaders.entrySet()) {
httpRequest.getHeaders().set(entry.getKey(), entry.getValue());
}
httpRequest.setThrowExceptionOnExecuteError(false);
return httpRequest.execute();
}

public HttpResponse sendCompleteMultipartUploadRequest(
String uri,
byte[] xmlBodyBytes,
String contentType,
Map<String, String> extensionHeaders)
throws IOException {
HttpRequest httpRequest =
requestFactory.buildPostRequest(
new GenericUrl(uri), new ByteArrayContent(contentType, xmlBodyBytes));
httpRequest.getHeaders().setContentType(contentType);
for (Map.Entry<String, String> entry : extensionHeaders.entrySet()) {
httpRequest.getHeaders().set(entry.getKey(), entry.getValue());
}
httpRequest.setThrowExceptionOnExecuteError(false);
return httpRequest.execute();
}

public HttpResponse sendAbortMultipartUploadRequest(
String uri, String contentType, Map<String, String> extensionHeaders)
throws IOException {
HttpRequest httpRequest = requestFactory.buildDeleteRequest(new GenericUrl(uri));
httpRequest.getHeaders().setContentType(contentType);
for (Map.Entry<String, String> entry : extensionHeaders.entrySet()) {
httpRequest.getHeaders().set(entry.getKey(), entry.getValue());
}
httpRequest.setThrowExceptionOnExecuteError(false);
return httpRequest.execute();
}

public HttpResponse sendListPartsRequest(
String uri, Map<String, String> extensionHeaders)
throws IOException {
HttpRequest httpRequest = requestFactory.buildGetRequest(new GenericUrl(uri));
for (Map.Entry<String, String> entry : extensionHeaders.entrySet()) {
httpRequest.getHeaders().set(entry.getKey(), entry.getValue());
}
httpRequest.setThrowExceptionOnExecuteError(false);
return httpRequest.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
import com.google.api.gax.rpc.HeaderProvider;
import com.google.api.gax.tracing.ApiTracerFactory;
import com.google.auth.Credentials;
import com.google.cloud.storage.Retrying.RetryingDependencies;
import com.google.cloud.ServiceFactory;
import com.google.cloud.ServiceRpc;
import com.google.cloud.TransportOptions;
import com.google.cloud.http.HttpTransportOptions;
import com.google.cloud.spi.ServiceRpcFactory;
import com.google.cloud.storage.BlobWriteSessionConfig.WriterFactory;
import com.google.cloud.storage.Retrying.DefaultRetrier;
import com.google.cloud.storage.Retrying.HttpRetrier;
import com.google.cloud.storage.Retrying.RetryingDependencies;
import com.google.cloud.storage.Storage.BlobWriteOption;
import com.google.cloud.storage.TransportCompatibility.Transport;
import com.google.cloud.storage.spi.StorageRpcFactory;
Expand Down Expand Up @@ -407,15 +405,7 @@ public Storage create(StorageOptions options) {
blobWriteSessionConfig = HttpStorageOptions.defaults().getDefaultStorageWriterConfig();
}
WriterFactory factory = blobWriteSessionConfig.createFactory(clock);
StorageImpl storage =
new StorageImpl(
httpStorageOptions,
factory,
new HttpRetrier(
new DefaultRetrier(
OtelStorageDecorator.retryContextDecorator(otel),
RetryingDependencies.simple(
options.getClock(), options.getRetrySettings()))));
StorageImpl storage = new StorageImpl(httpStorageOptions, factory, options.createRetrier());
return OtelStorageDecorator.decorate(storage, otel, Transport.HTTP);
} catch (IOException e) {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.storage;

import com.google.api.core.BetaApi;
import com.google.api.core.InternalExtensionOnly;
import com.google.cloud.storage.multipartupload.model.AbortMultipartUploadRequest;
import com.google.cloud.storage.multipartupload.model.AbortMultipartUploadResponse;
import com.google.cloud.storage.multipartupload.model.CompleteMultipartUploadRequest;
import com.google.cloud.storage.multipartupload.model.CompleteMultipartUploadResponse;
import com.google.cloud.storage.multipartupload.model.CreateMultipartUploadRequest;
import com.google.cloud.storage.multipartupload.model.CreateMultipartUploadResponse;
import com.google.cloud.storage.multipartupload.model.ListPartsRequest;
import com.google.cloud.storage.multipartupload.model.ListPartsResponse;
import com.google.cloud.storage.multipartupload.model.UploadPartRequest;
import com.google.cloud.storage.multipartupload.model.UploadPartResponse;
import java.io.IOException;
import java.net.URI;
import java.security.NoSuchAlgorithmException;

@BetaApi
@InternalExtensionOnly
public abstract class MultipartUploadClient {

MultipartUploadClient() {}

public abstract CreateMultipartUploadResponse createMultipartUpload(CreateMultipartUploadRequest request)
throws IOException;

public abstract UploadPartResponse uploadPart(UploadPartRequest request, RequestBody requestBody)
throws IOException, NoSuchAlgorithmException;

public abstract CompleteMultipartUploadResponse completeMultipartUpload(
CompleteMultipartUploadRequest request)
throws NoSuchAlgorithmException, IOException;

public abstract AbortMultipartUploadResponse abortMultipartUpload(AbortMultipartUploadRequest request)
throws IOException, NoSuchAlgorithmException;

public abstract ListPartsResponse listParts(ListPartsRequest listPartsRequest) throws IOException;

public static MultipartUploadClient create(MultipartUploadSettings config) {
HttpStorageOptions options = config.getOptions();
return new MultipartUploadClientImpl(
URI.create(options.getHost()),
options.getStorageRpcV1().getStorage().getRequestFactory(),
options.createRetrier(),
options);
}
}
Loading
Loading