Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 6b51855

Browse files
committed
JCLOUDS-1605: Return correct length in GCS getBlob
Range requests could cause the payload size to be smaller than the object size.
1 parent 44ec4b8 commit 6b51855

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

providers/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GoogleCloudStorageBlobStore.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,12 @@ public Blob getBlob(String container, String name, GetOptions options) {
250250
org.jclouds.http.options.GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
251251
MutableBlobMetadata metadata = objectToBlobMetadata.apply(gcsObject);
252252
Blob blob = new BlobImpl(metadata);
253-
// TODO: Does getObject not get the payload?!
254253
Payload payload = api.getObjectApi().download(container, Strings2.urlEncode(name), httpOptions).getPayload();
254+
long contentLength = payload.getContentMetadata().getContentLength();
255255
payload.setContentMetadata(metadata.getContentMetadata()); // Doing this first retains it on setPayload.
256256
blob.setPayload(payload);
257+
// getObject() returns the full object length but download() could be smaller due to range requests.
258+
payload.getContentMetadata().setContentLength(contentLength);
257259
return blob;
258260
}
259261

0 commit comments

Comments
 (0)