Tüm Ürünler
Search
Belge Merkezi

Object Storage Service:Yükleme ilerleme çubukları

Son Güncelleme:Oct 01, 2026

Nesnelerin yükleme ilerlemesini görüntülemek için ilerleme çubuklarını kullanabilirsiniz.

Notlar

  • Bu konuda Çin (Hangzhou) bölgesinin genel uç noktası kullanılmıştır. OSS ile aynı bölgedeki diğer Alibaba Cloud hizmetlerinden OSS'ye erişmek için dahili uç noktayı kullanın. OSS bölgeleri ve uç noktaları hakkında daha fazla bilgi için bkz. Bölgeler ve uç noktalar.

  • Bu konuda kimlik bilgileri ortam değişkenlerinden alınır. Kimlik bilgilerini yapılandırma hakkında daha fazla bilgi için bkz. Python 1.0 için OSS SDK kullanarak kimlik bilgilerini yapılandırma.

  • Bu konu, bir OSS uç noktası ile bir OSSClient örneğinin nasıl oluşturulacağını göstermektedir. Özel alan adı kullanma veya Security Token Service (STS) kimlik bilgileriyle kimlik doğrulama gibi alternatif yapılandırmalar için bkz. Başlatma.

Örnekler

Aşağıdaki örnek kod, bucket.put_object kullanarak bir nesne yüklerken ilerleme çubuğunun nasıl kullanılacağını gösterir:

# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
import oss2
from oss2.credentials import EnvironmentVariableCredentialsProvider
# Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
auth = oss2.ProviderAuthV4(EnvironmentVariableCredentialsProvider())

# Specify the endpoint of the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the endpoint to https://oss-cn-hangzhou.aliyuncs.com. 
endpoint = "https://oss-cn-hangzhou.aliyuncs.com"

# Specify the ID of the region that maps to the endpoint. Example: cn-hangzhou. This parameter is required if you use the signature algorithm V4.
region = "cn-hangzhou"

# Specify the name of your bucket.
bucket = oss2.Bucket(auth, endpoint, "yourBucketName", region=region)

# consumed_bytes specifies the size of data that has been uploaded. 
# total_bytes specifies the total size of data that you want to upload. If the size of the data that you want to upload cannot be determined, the value of the total_bytes parameter is None. 
def percentage(consumed_bytes, total_bytes):
    if total_bytes:
        rate = int(100 * (float(consumed_bytes) / float(total_bytes)))
        print('\r{0}% '.format(rate), end='')
        sys.stdout.flush()
# progress_callback is an optional parameter used to return progress information. 
bucket.put_object('yourObjectName', 'a'*1024*1024, progress_callback=percentage)

İlgili Bilgiler

Nesne yüklemesi sırasında ilerleme çubuğunun nasıl kullanılacağına ilişkin tam örnek kod için GitHub adresini ziyaret edin.