You can download objects stored in Object Storage Service (OSS) by using OSS SDK for Ruby. You can also directly download the objects over HTTP. To download an object over HTTP, you can use a browser or a command-line tool such as wget curl. In this case, you must use OSS SDK for Ruby to generate the URL of the object.

If you use the Bucket#object_url method to generate an HTTP address used to download the object, you must configure the following parameters:
  • key: the name of the object that you want to download.
  • sign: specifies whether to generate a signed URL.
    • If the access control list (ACL) of the object is public read or public read/write, you can access the object by using a URL that does not contain a signature.
    • If the ACL of the object is private, you must use a signed URL to access the object.
  • expires: the validity period of the URL. Default value: 60. Unit: seconds.


The following code provides an example on how to perform HTTP-based download:

require 'aliyun/oss'

client =
  # In this example, the endpoint of the China (Hangzhou) region is used. Specify your actual endpoint. 
  endpoint: '',
  # The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
  access_key_id: 'AccessKeyId', access_key_secret: 'AccessKeySecret')

# Specify the bucket name. Example: examplebucket. 
bucket = client.get_bucket('examplebucket')
# Generate a URL. By default, the URL contains a signature. The validity period is 60 seconds. 
puts bucket.object_url('my-object')

# Generate a URL that does not contain a signature. 
puts bucket.object_url('my-object', false)

# Set the validity period of the specified URL to 3600 seconds. 
puts bucket.object_url('my-object', true, 3600)