Google cloud storage 在google云存储中使用post方法时遇到问题-SignatureDesNotMatch

Google cloud storage 在google云存储中使用post方法时遇到问题-SignatureDesNotMatch,google-cloud-storage,Google Cloud Storage,在提交表单时,我尝试使用post方法将对象发布到google云存储 我收到“SignatureDesNotMatch”错误 我使用以下方法生成策略和签名: $secret_key = 'xxxxxxxxxxxxxxxxxxxx'; $policy_sting = '{"expiration": "2014-06-16T11:11:11Z" , "conditions": [ ["starts-with", "$key", ""], {"acl": "public-read" },

在提交表单时,我尝试使用post方法将对象发布到google云存储 我收到“SignatureDesNotMatch”错误

我使用以下方法生成策略和签名:

$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>


您从何处获取策略字符串?文档显示了一个非常不同的要签名的字符串:嗨,我使用的是POST方法:策略文档:我认为您使用的是HMAC而不是RSA。你为什么不使用GoogleAPI php客户端库?我想它有你需要的签名例程。谢谢,我会用openssl\u签名重写它。。。我尝试过使用google api php客户端和google_StorageService对象,但没有找到如何为新对象设置ACL设置您应该能够在创建新对象时设置ACL。如果你遇到困难,请随时提出新问题寻求帮助。