使用谷歌云存储的post方法遇到麻烦 - SignatureDoesNotMatch

时间:2013-07-13 10:34:02

标签: google-cloud-storage

我在提交表单时尝试使用post methord将对象发布到Google云端存储 我收到'SignatureDoesNotMatch'错误。

我使用以下内容生成策略和签名:

$secret_key = 'xxxxxxxxxxxxxxxxxxxx'; 

$policy_sting = '{"expiration": "2014-06-16T11:11:11Z" , "conditions": [   ["starts-with", "$key", ""],  
  {"acl": "public-read" },   {"bucket": "my-new-bucket"},   {"success_action_redirect": "my-url.html/success" },    
  ] }' ; 


$policy = base64_encode(utf8_encode ($policy_sting)); 
$signature = base64_encode(hash_hmac("sha256",$policy,$secret_key,true));

这是我的表格:

<? header('x-goog-project-id: xxxxxxxxxxxxxxxx'); ?>
<? header('x-goog-api-version: 1'); ?>



<form action="http://storage.googleapis.com/my-new-bucket" method="post" enctype="multipart/form-data">

<input type="text" name="key" value="">
<input type="hidden" name="acl" value="public-read">
<input type="hidden" name="GoogleAccessId" value="xxxxxxxxxxxxxxxxxxxxxxxxx">


<input type="hidden" name="policy" value="<?=$policy;?>">
<input type="hidden" name="signature" value="<?=$signature;?>">
<input type="hidden" name="bucket" value="my-new-bucket">

<input type="hidden" name="success_action_redirect" value="---------">

<input name="file" type="file">
<input type="submit" value="Upload">
</form>

如何解决SignatureDoesNotMatch错误?

0 个答案:

没有答案