mirror of https://github.com/apache/jclouds.git
JCLOUDS-1605: Return correct length in GCS getBlob
Range requests could cause the payload size to be smaller than the object size.
This commit is contained in:
parent
44ec4b8763
commit
6b51855365
|
@ -250,10 +250,12 @@ public final class GoogleCloudStorageBlobStore extends BaseBlobStore {
|
|||
org.jclouds.http.options.GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
|
||||
MutableBlobMetadata metadata = objectToBlobMetadata.apply(gcsObject);
|
||||
Blob blob = new BlobImpl(metadata);
|
||||
// TODO: Does getObject not get the payload?!
|
||||
Payload payload = api.getObjectApi().download(container, Strings2.urlEncode(name), httpOptions).getPayload();
|
||||
long contentLength = payload.getContentMetadata().getContentLength();
|
||||
payload.setContentMetadata(metadata.getContentMetadata()); // Doing this first retains it on setPayload.
|
||||
blob.setPayload(payload);
|
||||
// getObject() returns the full object length but download() could be smaller due to range requests.
|
||||
payload.getContentMetadata().setContentLength(contentLength);
|
||||
return blob;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue