更新时间:2022-09-13 GMT+08:00
分享

上传对象

以下代码展示如何上传对象至OBS:

NSString *filePath = [[NSBundle mainBundle]pathForResource:@"fileName" ofType:@"Type"];
OBSPutObjectWithFileRequest *request = [[OBSPutObjectWithFileRequest alloc]initWithBucketName:@"bucketname" objectKey:@"objectname" uploadFilePath:filePath];
// 上传进度
request.uploadProgressBlock = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
    NSLog(@"%0.1f%%",(float)floor(totalBytesSent*10000/totalBytesExpectedToSend)/100);
};
// 上传文件
[ client putObject:request completionHandler:^(OBSPutObjectResponse *response, NSError *error){
    NSLog(@"%@",response.etag);
}];

更多上传对象的信息,请参见上传对象

分享:

    相关文档

    相关产品