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

iOS中使用AWS上传zip文件到Minio上的oss平台上

1. 集成AWS相关库(千万不要用最新的版本,否则会出现风格化虚拟路径,找不到主机名)

pod 'AWSS3', '~> 2.10.0'
pod 'AWSCore', '~> 2.10.0'

2. 编写集成的相关代码

- (void)uploadFileToMinIO {NSString *endPoint = @"http://192.168.1.31:9000";        // 有的需要加端口,有的不需要NSString *accessKey = @"FDX7fP3XbXXCvwbAQfefUzOiGf";    //  minio后台申请的NSString *secretKey = @"QrtJww9vcEy383126ZRX4LxxSNo2iC03yy5lbnJQnTcA"; //  minio后台申请的NSString *bucketName = @"桶名"; // 从minio后台创建AWSEndpoint *endpoint = [[AWSEndpoint alloc] initWithRegion:AWSRegionUSEast1service:AWSServiceS3URL:[NSURL URLWithString:endPoint]];NSLog(@"czf007: requestURL: %@", endpoint.URL.absoluteString);AWSStaticCredentialsProvider *credentialsProvider =[[AWSStaticCredentialsProvider alloc] initWithAccessKey:accessKeysecretKey:secretKey];AWSServiceConfiguration *configuration =[[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1endpoint:endpointcredentialsProvider:credentialsProvider];//    [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;    // 这个不能设置,会导致走虚拟化路径,使用下面的方式即可[AWSS3 registerS3WithConfiguration:configuration forKey:@"MinIO"];AWSS3PutObjectRequest *putRequest = [AWSS3PutObjectRequest new];putRequest.bucket = bucketName;putRequest.key = @"yourfile.zip";putRequest.body = [NSURL fileURLWithPath:@"/work/redsocks.zip"];putRequest.contentType = @"application/zip";// 设置 contentLength,防止 ExcessData 错误NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:@"/work/redsocks.zip" error:nil];NSNumber *fileSizeNumber = [attrs objectForKey:NSFileSize];putRequest.contentLength = fileSizeNumber;NSLog(@"czf007: uploading file with size: %@", fileSizeNumber);[[AWSS3 S3ForKey:@"MinIO"] putObject:putRequestcompletionHandler:^(AWSS3PutObjectOutput * _Nullable response, NSError * _Nullable error) {if (error) {NSLog(@"czf007:upload failed: %@", error);} else {NSLog(@"czf007:upload success!");}}];}

3. 查看日志

4. 在Minio后台查看文件是否上传成功


文章转载自:

http://LJ9sMm7o.pwgzh.cn
http://IA7lYxcI.pwgzh.cn
http://8vmsKDVJ.pwgzh.cn
http://FNvMdpgX.pwgzh.cn
http://S4wcXN4F.pwgzh.cn
http://EG3Svx2S.pwgzh.cn
http://8zuwgMd2.pwgzh.cn
http://YaZjF0ve.pwgzh.cn
http://UbSlnp92.pwgzh.cn
http://Rs5rd4eI.pwgzh.cn
http://suTM6Vot.pwgzh.cn
http://yN0doPTa.pwgzh.cn
http://UPWf4cC6.pwgzh.cn
http://B6OveMEd.pwgzh.cn
http://notlTs2W.pwgzh.cn
http://3LW7rIxH.pwgzh.cn
http://XvTTppCS.pwgzh.cn
http://at2k40xf.pwgzh.cn
http://umENEJ1O.pwgzh.cn
http://YBldXj2h.pwgzh.cn
http://spzLhR9Q.pwgzh.cn
http://R1ClQqhL.pwgzh.cn
http://XrG2YJBH.pwgzh.cn
http://0zwXjD6B.pwgzh.cn
http://p4dP1ENI.pwgzh.cn
http://6OZ1Bm7U.pwgzh.cn
http://wgDNiVIw.pwgzh.cn
http://ksDxTqDD.pwgzh.cn
http://0PIiv0Kl.pwgzh.cn
http://IcK97Q9F.pwgzh.cn
http://www.dtcms.com/a/145856.html

相关文章:

  • 使用Matlab工具将RAW文件转化为TXT文件,用于FPGA仿真输入
  • 用Mac M4构建多架构Docker镜像指南
  • 若依框架免登陆、页面全屏显示、打开新标签页(看板大屏)
  • neo4j-community-3.5.5-unix.tar.gz安装
  • SpringBoot + Vue 实现云端图片上传与回显(基于OSS等云存储)
  • map和set封装
  • 开源身份和访问管理(IAM)解决方案:Keycloak
  • 信息收集之hack用的网络空间搜索引擎
  • 快速搭建 Cpolar 内网穿透(Mac 系统)
  • Spark-SQL连接Hive全攻略
  • 基础服务系列-Jupyter Notebook 支持JavaScript
  • 解决使用hc595驱动LED数码管亮度低的问题
  • MetaGPT智能体框架深度解析:记忆模块设计与应用实践
  • Versal Adaptive SoC AI Engine 知识分享6
  • 一图掌握 C++ 核心要点
  • 【阿里云大模型高级工程师ACP习题集】2.1 用大模型构建新人答疑机器人
  • 在CSDN的1095天(创作纪念日)
  • uniapp打ios包
  • 【数据结构和算法】4. 链表 LinkedList
  • uniapp-商城-31-shop页面中的 我的订单
  • 【SpringBoot】HttpServletRequest获取使用及失效问题(包含@Async异步执行方案)
  • VLA论文精读(十四)PointVLA: Injecting the 3D World into Vision-Language-Action Models
  • k8s之 kube-prometheus监控
  • 4U带屏基于DSP/ARM+FPGA+AI的电力故障录波装置设计方案,支持全国产化
  • [FPGA基础] 时钟篇
  • CentOS7安装MySQL教程
  • 排序模型(Learning to Rank)
  • 检测IP地址欺诈风险“Scamalytics”
  • 深度解析算法之位运算
  • 无人船 | 图解基于PID控制的路径跟踪算法(以全驱动无人艇WAMV为例)