美文网首页
华为云图片上传数组越界错误

华为云图片上传数组越界错误

作者: 梵虚 | 来源:发表于2021-09-01 12:20 被阅读0次

最近使用华为云发现一个数组越界的错误,代码完全参照官方的demo,就是提示失败,后面发现是URL的问题,安卓在HuaWeiEndpoint的时候不需要加Http头,但是苹果这边必须要加,否则会出现数组越界的错误

 OBSStaticCredentialProvider *creadentailProvider = [[OBSStaticCredentialProvider alloc] initWithAccessKey:HuaWeiAccess_key_id secretKey:HuaWeiSecret_key authVersion:OBSAuthVersionV4];
            OBSServiceConfiguration *conf = [[OBSServiceConfiguration alloc] initWithURL:[NSURL URLWithString:HuaWeiEndpoint] credentialProvider:creadentailProvider];
            OBSClient *client = [[OBSClient alloc] initWithConfiguration:conf];
            NSString *strKey = [NSString stringWithFormat:@"user/%@avator%ld.jpg",self.mineModel.uid,theFianl];
            OBSPutObjectWithFileRequest *requestUplodad = [[OBSPutObjectWithFileRequest alloc] initWithBucketName:HuaWeiBucket objectKey:strKey uploadFilePath:strFilePath];
            requestUplodad.storageClass = OBSStorageClassGlacier;
            requestUplodad.uploadProgressBlock = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
                NSLog(@"%0.1f%%",(float)floor(totalBytesSent*10000/totalBytesExpectedToSend)/100);
            };
            OBSBFTask *pushTask = [client putObject:requestUplodad completionHandler:^(OBSPutObjectResponse *response, NSError *error) {
                if (error) {
                    NSLog(@"error is %@",error.description);
                }else{
                    NSString *imagePath = [NSString stringWithFormat:@"/user/%@avator%ld.jpg",self.mineModel.uid,theFianl];
                   NSLog(@"imagePath = %@",imagePath);
                }
                [[NSFileManager defaultManager] removeItemAtPath:strFilePath error:nil];
            }];
            [pushTask waitUntilFinished];

相关文章

  • 华为云图片上传数组越界错误

    最近使用华为云发现一个数组越界的错误,代码完全参照官方的demo,就是提示失败,后面发现是URL的问题,安卓在Hu...

  • iOS上传图片数组越界

    需求是这样的,通过相册选择照片后立即显示在view中,然后在想后台发送照片。这时,如果网络慢的情况下,照片还在上传...

  • java.lang.ArrayIndexOutOfBoundsE

    名字上看是数组下标越界错误,解决方法就是查看为什么下标越界。 如下: 12代表越界数组的下标, originalD...

  • flutter 与 iOS 交互

    由于单位项目中上传图片功能用的是华为云,flutter暂时好像还没有相关插件,所以只能想到去调用原生进行图片上传,...

  • 华为云 obs上传图片(vue)

    各大平台oss都已支持前端直接调用第三方sdk上传文件,但是华为云前端上传可查资料比较少,就连文档感觉只对后端友善...

  • Amplify亚马逊云上传图片

    最近公司需要把图片上传从华为云改成亚马逊云,记录一下操作流程,最早亚马逊云是使用AWS的库来进行上传,但是最近亚马...

  • Java中的数组

    数组的申请:动态数组 静态数组的初始化 常见的错误(exception) +数组索引越界 //即访问不存在的索引+...

  • 第五天

    一、错误处理 1、Error 1.1 2、panic(致命错误:数组越界、空指针等) 2.1 显示调用 2.2 被...

  • 华为云文件上传操作记录 2022-09-17

    华为云文件上传操作记录

  • iOS代码检查清单

    检查代码是否规范,持续更新 数组越界 NSRange越界 网络数据类型转换错误 系统方法JSON反序列化参数为空 ...

网友评论

      本文标题:华为云图片上传数组越界错误

      本文链接:https://www.haomeiwen.com/subject/ctuxwltx.html