0

我正在尝试使用 post 方法将对象发布到谷歌云存储,提交表单时出现“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 错误?

4

0 回答 0