mirror of https://github.com/apache/jclouds.git
JCLOUDS-1400: Honor GCS signed URL content type
Also add GetOptions headers instead of replacing all headers.
This commit is contained in:
parent
a35fa4a404
commit
7db5eb5cd0
|
@ -24,6 +24,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.security.PrivateKey;
|
||||
import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Provider;
|
||||
|
@ -95,7 +96,8 @@ public final class GoogleCloudStorageBlobRequestSigner implements BlobRequestSig
|
|||
|
||||
@Override
|
||||
public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) {
|
||||
return sign("PUT", container, blob.getMetadata().getName(), GetOptions.NONE, timestamp.get() + timeInSeconds, null);
|
||||
return sign("PUT", container, blob.getMetadata().getName(), GetOptions.NONE, timestamp.get() + timeInSeconds,
|
||||
blob.getMetadata().getContentMetadata().getContentType());
|
||||
}
|
||||
|
||||
private HttpRequest sign(String method, String container, String name, GetOptions options, long expires, String contentType) {
|
||||
|
@ -125,11 +127,14 @@ public final class GoogleCloudStorageBlobRequestSigner implements BlobRequestSig
|
|||
}
|
||||
String signature = BaseEncoding.base64().encode(rawSignature);
|
||||
|
||||
for (Map.Entry<String, String> entry : options.buildRequestHeaders().entries()) {
|
||||
request.addHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return (HttpRequest) request
|
||||
.addQueryParam("Expires", String.valueOf(expires))
|
||||
.addQueryParam("GoogleAccessId", creds.get().identity)
|
||||
.addQueryParam("Signature", signature)
|
||||
.headers(options.buildRequestHeaders())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue