Help Center/ Object Storage Service/ SDK Reference/ iOS/ Object APIs/ Basic Operations/ Object Upload/ Performing an Appendable Upload
Updated on 2026-07-22 GMT+08:00
Performing an Appendable Upload
Appendable upload allows you to upload an object in appending mode and then append data to the object. You can call appendObject to perform an appendable upload. Sample code is as follows:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"FileName" ofType:@"FileSuffix"];
NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary *fileDic = [manager attributesOfItemAtPath:filePath error:nil];
unsigned long long size = [[fileDic objectForKey:NSFileSize] longLongValue];
int filesize = size;
//Create an object in appendable mode.
OBSAppendObjectWithFileRequest *request = [[OBSAppendObjectWithFileRequest alloc] initWithBucketName:@"bucketName" objectKey:@"objectname" uploadFilePath:filePath];
request.position = [NSNumber numberWithFloat:0];
request.uploadProgressBlock = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
NSLog(@"%0.1f%%",(float)floor(totalBytesSent*10000/totalBytesExpectedToSend)/100);
};
__block NSString* nextPosition = nil;
[client appendObject:request completionHandler:^(OBSAppendObjectResponse *response, NSError *error) {
NSLog(@"%@",response);
//Start position for next appending
NSDictionary *temp = [response headers];
nextPosition = [temp valueForKey:@"x-obs-next-append-position"];
NSLog(@"nextPosition:%@", nextPosition);
}];
//Append data to the object.
request = [[OBSAppendObjectWithFileRequest alloc] initWithBucketName:@"bucketName" objectKey:@"objectname" uploadFilePath:filePath];
int nextPositionInt = [nextPosition intValue];
request.position = [NSNumber numberWithInt:nextPositionInt];
request.uploadProgressBlock = ^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
NSLog(@"%0.1f%%",(float)floor(totalBytesSent*10000/totalBytesExpectedToSend)/100);
};
[client appendObject:request completionHandler:^(OBSAppendObjectResponse *response, NSError *error) {
NSLog(@"%@",response);
//Start position for next appending
NSDictionary *temp = [response headers];
nextPosition = [temp valueForKey:@"x-obs-next-append-position"];
NSLog(@"nextPosition:%@", nextPosition);
}];
- Objects uploaded using putObject, referred to as normal objects, can overwrite objects uploaded using appendObject, referred to as appendable objects. Data cannot be appended to an appendable object anymore once the object has been overwritten by a normal object.
- When you upload an object for the first time in appendable mode, an exception will be reported (HTTP status code 409) if a common object with the same name is already present.
- The ETag returned for an appendable upload is the ETag for the uploaded content, rather than that of the whole object.
- Data appended each time can be up to 5 GB, and 10000 times of appendable uploads can be performed on a single object.
- After an appendable upload is successful, you can obtain the start position for next appending using the following method or using the getObjectMetadata API.
NSDictionary *temp = [response headers];NSString* nextPosition = [temp valueForKey:@"x-obs-next-append-position"];
Parent topic: Object Upload
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot