更新时间:2025-04-03 GMT+08:00
        
          
          
        
      
      
      
      
      
      
      
      
  
      
      
      
        
上传对象
本示例用于将本地文件上传到桶名为“bucketname”里,名称为“objectname”。
代码示例如下:
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);
}];
 
   父主题: 快速入门
  
  
   
    