Büyük bir nesneyi yüklemek uzun sürüyorsa, nesnenin tamamı yüklenene kadar veriyi sürekli olarak göndermek için akışlı yükleme yöntemini kullanabilirsiniz.
Örnekler
Aşağıdaki kod, bir nesnenin akışlı yükleme yöntemiyle nasıl yükleneceğini gösterir:
require 'aliyun/oss'
client = Aliyun::OSS::Client.new(
# This example uses the China (Hangzhou) endpoint. Replace it with the endpoint for your region.
endpoint: 'https://oss-cn-hangzhou.aliyuncs.com',
# Obtain access credentials from environment variables. Before you run this sample code, configure the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables.
access_key_id: ENV['OSS_ACCESS_KEY_ID'],
access_key_secret: ENV['OSS_ACCESS_KEY_SECRET']
)
# Specify the bucket name. For example, examplebucket.
bucket = client.get_bucket('examplebucket')
# Specify the full path of the object. Do not include the bucket name in the full path. For example, exampleobject.txt.
bucket.put_object('exampleobject.txt') do |stream|
100.times { |i| stream << i.to_s }
end