各位大神,我写了段代码列出某个bucket下面的所有object提示SignatureDoesNotMatch,参照的是
http://helpcdn.aliyun.com/document_detail/oss/sdk/c-sdk/get-started.html写的。代码我贴出来,大家看看有没有什么不对的:
int main(int argc, char **argv)
{
if (aos_http_io_initialize("oss_test", 0) != AOSE_OK)
{
exit(1);
}
aos_pool_t *p;
int is_oss_domain = 0;
oss_request_options_t *oss_request_options;
aos_pool_create(&p, NULL);
//init_oss_request_options
oss_request_options = oss_request_options_create(p);
oss_request_options->config = oss_config_create(oss_request_options->pool);
aos_str_set(&oss_request_options->config->host, "oss-cn-hangzhou.aliyuncs.com");
oss_request_options->config->port = 80;
aos_str_set(&oss_request_options->config->id, "abcdef");
aos_str_set(&oss_request_options->config->key, "XXXXXXXX");
oss_request_options->config->is_oss_domain = is_oss_domain;
oss_request_options->ctl = aos_http_controller_create(oss_request_options->pool, 0);
aos_status_t *s;
aos_table_t *resp_headers;
aos_string_t bucket;
char *bucket_name = "/mydomain/a/b/c/d/e/";
oss_list_object_params_t *params;
aos_str_set(&bucket, bucket_name);
resp_headers = aos_table_make(p, 0);
s = aos_status_create(p);
params = oss_create_list_object_params(p);
params->max_ret = 20;
s = oss_list_object(oss_request_options, &bucket, params, &resp_headers);
aos_pool_destroy(p);
aos_http_io_deinitialize();
return 0;
}
调用oss_list_object函数后调试信息如下:
s = 0x02720ee0 {code=403 error_code=0x027214e0 "SignatureDoesNotMatch" error_msg=0x027214f8 "The request signature we calculated does not match the signature you provided. Check your key and signing method." ...}
实际上,如果我在浏览器中输入以下地址,访问某个object时,是可以的。就像下面这样:
http://mydomain.oss-cn-hangzhou.aliyuncs.com/a/b/c/d/e/f.txt?OSSAccessKeyId=abcdef&Expires=1448637894&Signature=1234509876%5f7DEAop
这样浏览器就可以直接显示该文件的内容。
示例代码里面也没看到要提供Signature,而且我是访问bucket,列出里面的object。求大神帮忙解答,谢谢。
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。