Updated on 2025-04-03 GMT+08:00
Uploading an object
This example uploads a local file to bucket bucketname as object objectname.
Sample code:
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"fileName" ofType:@"Type"]; OBSPutObjectWithFileRequest *request = [[OBSPutObjectWithFileRequest alloc]initWithBucketName:@"bucketname" objectKey:@"objectname" uploadFilePath:filePath]; // Query the upload progress. request.uploadProgressBlock = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) { NSLog(@"%0.1f%%",(float)floor(totalBytesSent*10000/totalBytesExpectedToSend)/100); }; // Upload a file. [ client putObject:request completionHandler:^(OBSPutObjectResponse *response, NSError *error){ NSLog(@"%@",response.etag); }];
Parent topic: Quick Start
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.
