对象相关接口 代码示例 cpp bool S3Demo::PutObjectTagging() { const Aws::String objectname " "; Aws::S3::Model::PutObjectTaggingRequest request; request.SetBucket(" "); request.SetKey(objectname); Aws::S3::Model::Tagging tagging; tagging.AddTagSet(Aws::S3::Model::Tag().WithKey("key1").WithValue("value1")); tagging.AddTagSet(Aws::S3::Model::Tag().WithKey("key2").WithValue("value2")); request.SetTagging(tagging); Aws::S3::Model::PutObjectTaggingOutcome outcome s3client>PutObjectTagging(request); if (outcome.IsSuccess()) { std::cout "; long expirationInSeconds 900; Aws::String path s3client>GeneratePresignedUrl(" ", objectname, Aws::Http::HttpMethod::HTTPGET, expirationInSeconds); std::cout << "GeneratePresignUrl: " << path << std::endl; return true; } 生成下载对象的预签名URL后,可以通过该URL下载文件: cpp void S3Demo::GetObjUsingPresignedUrl(const std::string& url, const std::string& filepath) { try { std::ofstream file(filepath, std::ios::binary); if (!file.isopen()) { std::cerr << "Failed to open file for writing: " << filepath << std::endl; return; } curlpp::Easy request; request.setOpt(curlpp::options::Url(url)); request.setOpt(curlpp::options::WriteStream(&file)); request.perform(); std::cout << "Download successful: " << filepath << std::endl; } catch (curlpp::RuntimeError& e) { std::cerr << "Runtime Error: " << e.what() << std::endl; } catch (curlpp::LogicError& e) { std::cerr << "Logic Error: " << e.what() << std::endl; } }