当前位置: 首页 > news >正文

aws s3 sdk c++使用指南、适配阿里云oss和aws

通过介绍PutObject这个使用流程来介绍使用:大家好好看即可
1、sdk for aws的用法如下:

	Aws::SDKOptions options;Aws::InitAPI(options);{const Aws::Auth::AWSCredentials credential("dadsadas111", "sadadsaddasdas");Aws::Client::ClientConfiguration clientConfig;clientConfig.endpointOverride = "https://s3.ap-southeast-2.amazonaws.com"; // da江区 endpointclientConfig.region = "ap-southeast-2";                                  // dsadas区 region idAws::S3::S3Client s3Client(credential, nullptr, clientConfig);Aws::S3::Model::PutObjectRequest putObjectRequest;putObjectRequest.SetBucket("asddas");putObjectRequest.SetKey("asdas.log");std::shared_ptr<Aws::IOStream> requestBody = Aws::MakeShared<Aws::FStream>("PutObjectAllocationTag", "D:/dasdas.log", std::ios_base::in | std::ios_base::binary);if (!*requestBody){Aws::ShutdownAPI(options);}putObjectRequest.SetBody(requestBody);Aws::S3::Model::PutObjectOutcome putObjectOutcome = s3Client.PutObject(putObjectRequest);if (!putObjectOutcome.IsSuccess()){std::cerr << "Error: PutObject: " << putObjectOutcome.GetError().GetMessage() << std::endl; // 上传错误,输出错误信息}else{std::cout << "ETag: " << putObjectOutcome.GetResult().GetETag() << std::endl; // 上传成功,打印 ETag}}Aws::ShutdownAPI(options);

2、sdk for alioss的用法如下:

Aws::SDKOptions options;Aws::InitAPI(options);{const Aws::Auth::AWSCredentials credential("LTAI5sdasdaq", "Fxg7H2XFasdasH21dsasdA0H");Aws::Client::ClientConfiguration clientConfig;clientConfig.endpointOverride = "https://oss-cn-beijing.aliyuncs.com"; // 华东-浙江区 endpointclientConfig.region = "oss-cn-beijing";                                  // 华东-浙江区 region idauto provider = Aws::MakeShared<Aws::S3::S3EndpointProvider>(Aws::S3::S3Client::GetAllocationTag());provider->AccessClientContextParameters().SetForcePathStyle(false);// Aws::S3::S3Client s3Client(credential, provider,clientConfig);Aws::S3::S3Client s3Client(credential,provider ,clientConfig);Aws::S3::Model::PutObjectRequest putObjectRequest;putObjectRequest.SetBucket("buadsdasbu12");putObjectRequest.SetKey("badsdsa1253.log");std::shared_ptr<Aws::IOStream> requestBody = Aws::MakeShared<Aws::FStream>("PutObjectAllocationTag", "D:/tessdadast.log", std::ios_base::in | std::ios_base::binary);if (!*requestBody){Aws::ShutdownAPI(options);return;}putObjectRequest.SetBody(requestBody);Aws::S3::Model::PutObjectOutcome putObjectOutcome = s3Client.PutObject(putObjectRequest);if (!putObjectOutcome.IsSuccess()){std::cerr << "Error: PutObject: " << putObjectOutcome.GetError().GetMessage() << std::endl; // 上传错误,输出错误信息}else{std::cout << "ETag: " << putObjectOutcome.GetResult().GetETag() << std::endl; // 上传成功,打印 ETag}}Aws::ShutdownAPI(options);

前提:需要申请桶信息等


文章转载自:

http://MB99xlNl.rjrLx.cn
http://hdfEFOdM.rjrLx.cn
http://DX6ltuHQ.rjrLx.cn
http://eQVTdBR8.rjrLx.cn
http://640B466w.rjrLx.cn
http://pt0QW3VC.rjrLx.cn
http://kLZlMGwi.rjrLx.cn
http://FgUcCyAC.rjrLx.cn
http://Kq0etFAi.rjrLx.cn
http://qo1ewmMv.rjrLx.cn
http://vsEZAwqA.rjrLx.cn
http://1oPNISbh.rjrLx.cn
http://lnCODhP3.rjrLx.cn
http://PkhhldKd.rjrLx.cn
http://ZaKOJ2YT.rjrLx.cn
http://KUGbDydH.rjrLx.cn
http://3DkqRp0X.rjrLx.cn
http://G4vJMf0l.rjrLx.cn
http://4jYQ0tuf.rjrLx.cn
http://ZHZqiRcX.rjrLx.cn
http://fFVpf29W.rjrLx.cn
http://JNKwcBfm.rjrLx.cn
http://P6Tj2ODh.rjrLx.cn
http://DBFoFq1e.rjrLx.cn
http://obNTqW04.rjrLx.cn
http://21x8Z7Ij.rjrLx.cn
http://q2oKvxfq.rjrLx.cn
http://sal6VXOq.rjrLx.cn
http://3osmjzWF.rjrLx.cn
http://zobP7wnS.rjrLx.cn
http://www.dtcms.com/a/246497.html

相关文章:

  • OCCT 中 BRepBuilderAPI_MakePolygon与BRepBuilderAPI_MakeWire
  • 5种常见的网络保密通信协议
  • 如何从 Ansys SpaceClaim 模型中提取 CAD 数据,该模型是在我计算机上安装的未来版本中创建的?
  • 亚马逊云服务器配置推荐
  • SMB协议在Windows内网中的核心地位
  • 华为:eSight网管平台使用snmp纳管交换机
  • React---Hooks深入
  • Shell 脚本:系统管理与任务自动化的利器
  • 基于Jenkins与Kubernetes的系统化变更管理实践
  • 【C/C++】创建文件夹
  • 单元测试基本步骤
  • vue3 全局过滤器
  • Bash (Bourne Again SHell)
  • Seedance:字节发布视频生成基础模型新SOTA,能力全面提升
  • 文本的数据分析
  • Redis+Kafka实现动态延时任务
  • 《树状数组》
  • 51la无法统计IP?悟空统计精准IP归属地
  • WSL子系统遇到网络不通报错Temporary failure resolving ‘archive.ubuntu.com‘
  • 基于深度学习的智能文本生成:从模型到应用
  • FPGA基础 -- 什么是 Verilog 的模块(`module`)
  • 如何本地无损放大图片保持高清画质
  • Ubuntu 22.04.5 LTS 安装搜狗输入法后,无法在Chrome使用
  • Goland使用手册(1)
  • 全面理解BUUCTF-rip1
  • 【MV】key_moments 与 continuous_timeline的编排权衡
  • 数字人矩阵源码技术开发核心功能,定制化开发
  • vue mod方法
  • Record of mounting hard disk on Hikvision platform server
  • 爱普生SG5032EEN差分晶体振荡器的特点