C++ can';t通过查询字符串身份验证访问Amazon s3数据

C++ can';t通过查询字符串身份验证访问Amazon s3数据,c++,amazon-web-services,amazon-s3,authorization,C++,Amazon Web Services,Amazon S3,Authorization,我下面的代码用于访问AmazonS3以获取.zip文件。 我的请求url如下所示: http://xxx.s3.amazonaws.com/Pack1A.zip?AWSAccessKeyId=AKIAIEMQY4BEQUOCUP7Q&Expires=1298945115&Signature=sxoXZ4y7osXjn IycQynGbE9%2Bb5E%3D 代码段: time_t rawtime; time(&rawtime); gHttpDownloader->SetRequ


我下面的代码用于访问AmazonS3以获取.zip文件。 我的请求url如下所示:
http://xxx.s3.amazonaws.com/Pack1A.zip?AWSAccessKeyId=AKIAIEMQY4BEQUOCUP7Q&Expires=1298945115&Signature=sxoXZ4y7osXjn
IycQynGbE9%2Bb5E%3D

代码段:

time_t rawtime;
time(&rawtime); 

gHttpDownloader->SetRequestHeader("Authorization","AWS AKIAIEMQY4BEQUOCUP7Q:aN6bjwDkeZXIHDrqk3MHlj4shl0%3D");
gHttpDownloader->SetRequestHeader("Authorization", buf);
gHttpDownloader->SetRequestHeader("Cache-Control", "max-age=0");
gHttpDownloader->SetRequestHeader("Accept","application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*;q=0.5");
gHttpDownloader->SetRequestHeader("Accept-Encoding", "gzip,deflate,sdch");
gHttpDownloader->SetRequestHeader("Accept-Language", "en-GB");
gHttpDownloader->SetRequestHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3");
gHttpDownloader->Post(gURL, NULL,0,GotHeaders, NULL);

............ //GotHeaders is a callback function that reads input from the response.

它总是打印403禁止的错误。有人能告诉我为什么吗?

确保所有ACL都设置正确

示例URL使用
查询字符串身份验证
,但代码示例显示正在设置
授权
。您只需要设置其中一个。看


还有一个AWS。

我遇到了一个类似的问题,从web浏览器请求预签名URL是成功的,但是直接从PHP请求导致失败。在做了一些挖掘之后,我了解到要模拟web浏览器,您需要传递一个带有空值的
内容类型
标题

中提供了以下示例:


<?php
$s3 = new AmazonS3();

// Generate the URL
$url = $s3->get_object_url('my-bucket', 'folder/file.txt', '5 minutes');

// Try to fetch the URL so we can get the status code
$http = new CFRequest($url);
$http->add_header('Content-Type', ''); # Simulate a web browser
$http->send_request(true);

echo $http->get_response_code();
#=> 200
?>