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

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

作者: 梵虚 | 来源:发表于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];
    

    相关文章

      网友评论

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

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