Tüm Ürünler
Search
Belge Merkezi

Object Storage Service:Progress bar (iOS SDK)

Son Güncelleme:Oct 01, 2026

Yüklenen veya indirilen bir nesnenin ilerleme durumunu göstermek için bir ilerleme çubuğu kullanabilirsiniz. Bu örnekte, yüklenen bir nesnenin ilerleme çubuğunun nasıl görüntüleneceğini açıklamak için PutObject işlemi kullanılmıştır.

Notlar

  • Bu konudaki örnek kodu çalıştırmadan önce, özel alan adı veya Security Token Service (STS) gibi yöntemleri kullanarak bir OSSClient örneği oluşturmanız gerekir. Daha fazla bilgi için bkz. Başlatma.

    Not

    Paket bölgesi, başlatma sırasında belirtilen uç noktanın bölgesine göre belirlenir.

  • Bir dosya yüklemek için oss:PutObject iznine sahip olmalısınız. Daha fazla bilgi için bkz. RAM kullanıcılarına özel erişim ilkeleri atama.

Örnekler

Aşağıdaki örnek kod, yerel bir dosyayı bir pakete yüklerken ilerleme çubuğunun nasıl görüntüleneceğini göstermektedir:

OSSPutObjectRequest * put = [OSSPutObjectRequest new];
// Specify the name of the bucket. Example: examplebucket. 
put.bucketName = @"examplebucket";
// Specify the full path of the object. Do not include the bucket name in the full path. Example: exampledir/exampleobject.txt. 
put.objectKey = @"exampledir/exampleobject.txt";
// Specify the full path of the local file that you want to upload. 
// By default, if you do not specify the full path of the local file, the local file is uploaded from the path of the project to which the sample program belongs. 
put.uploadingFileURL = [NSURL fileURLWithPath:@"filePath"];
// Configure the progress callback function to display the progress bar. 
put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
    // Specify the number of bytes that are being uploaded, the total number of bytes that are uploaded, and the total number of bytes that you want to upload. 
    NSLog(@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
};
OSSTask * putTask = [client putObject:put];
[putTask continueWithBlock:^id(OSSTask *task) {
    if (!task.error) {
        NSLog(@"upload object success!");
    } else {
        NSLog(@"upload object failed, error: %@" , task.error);
    }
    return nil;
}];
// Implement synchronous blocking to wait for the task to complete. 
// [putTask waitUntilFinished]; 

İlgili Konular

  • Nesne yükleme işlemlerinde ilerleme çubuklarının kullanıldığı tam örnek kod için GitHub adresini ziyaret edin.

  • Bir OSSClient örneğinin nasıl başlatılacağı hakkında daha fazla bilgi için bkz. Başlatma.