从 AWS S3 存储桶下载文件

时间:2021-06-30 05:17:30

标签: c++ amazon-web-services amazon-s3 c++17 libcurl

我正在尝试使用我在 github 上找到的以下代码通过我的 AWS S3 存储桶下载文件:curl_bazek

通过修复代码中的一些问题,我能够使其正常工作。硬编码访问和秘密密钥并将时间调整为 GMT。但我不知道如何下载文件。

这是我的输出,您可以看到 test.dll 位于此存储桶中:

AWSSecretKey=XXXXXXX
https://XXXXXX.s3.amazonaws.com
<?xml version="1.0" encoding="UTF-8"?>
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>atmaple</Name><Prefix>

</Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated><Contents><Key>test.dll</Key>
<LastModified>2021-06-29T16:18:40.000Z</LastModified>
<ETag>&quot;XXXXXXXXXXXXX&quot;</ETag>
<Size>45634048</Size><Owner><ID>XXXXXXXXXXXXX</ID></Owner><StorageClass>STANDARD</StorageClass></Contents></ListBucketResult>

更改网址会导致我出错。

std::string hostS3Bucket = bucketName + ".s3.amazonaws.com/test.dll";

更改 curl url 也会导致相同的效果。

curl_easy_setopt(curl, CURLOPT_URL, ("https://" + hostS3Bucket + "/test.dll").c_str());

错误:

The specified bucket is not valid.

1 个答案:

答案 0 :(得分:0)

"This is an example, (<acronym class=\"ticker\">AVEO</acronym>) and here is some more text, (<acronym class=\"ticker\">IBM</acronym>) and finally the last piece: (<acronym class=\"ticker\">AAPL</acronym>).  That is all"

What we need to do, is within that entire block, take every occurrence where the string (<acronym class=\"ticker\">AVEO</acronym>) is, and replace it with an actual link, like this:   <a href="http://www.website.com/stock/quote/AVEO">AVEO</a>.

这对我有用。我通过内存加载 .dll,所以我不需要处理实际写入磁盘,但如果需要,SDK 似乎也会处理这个。

问候