1
Googleストレージにファイルをダウンロードするための署名付きURLを取得しようとすると問題があります。 SignatureDoesNotMatchエラーを取得しています。Google Cloud signed URL + SignatureDoesNotMatch
private String signString(GoogleCredential credential, String stringToSign) throws Exception {
// sign data
Signature signer = Signature.getInstance("SHA256withRSA");
signer.initSign(credential.getServiceAccountPrivateKey());
signer.update(stringToSign.getBytes("UTF-8"));
byte[] rawSignature = signer.sign();
return new String(org.apache.commons.codec.binary.Base64.encodeBase64(rawSignature, false), "UTF-8");
}
//Here is the code to get signed url
private getFileUrl(GoogleCredential credential,String bucketName, String filePath) {
String signedParam = signString(credential, "GET\n\n\n"+expiration+"\n"+bucketName+"/"+filePath);
// construct URL
String url = "http://storage.googleapis.com/" + bucketName + "/" + filePath +
"?GoogleAccessId=" + credential.getServiceAccountId() +
"&Expires=" + expiration +
"&Signature=" + URLEncoder.encode(signedParam, "UTF-8");
return url;
}
私はここで何も足りませんか?これとしばらくの間闘っています。どんな助けでも大歓迎です。
ありがとうございました。