aliyun-sdk 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36daab0f73cf740bf403be9a9dfdec680bf91e13
4
- data.tar.gz: efebb230b85672b7785ddc167b186859ff330d83
3
+ metadata.gz: b400456da8877a797a2caecc64fd696f54f129f3
4
+ data.tar.gz: 0bc030c00b7bc81a234bfa7ac52db10a1cbc7f71
5
5
  SHA512:
6
- metadata.gz: 690da0dbe97a706c46a67fd5384ab2ec1c7fec65cfab7c5a7b27bc3e9696f4283ee6314eea6ce00f725b60b6a225f091b936cd8e804482ef005c996ec9e85361
7
- data.tar.gz: 19bd7510ef836532f657604e1bd12a1e8e404863a8d317c551bdf7c640740344325a7ca12bb52f5f104d370b8c6f3e93efe7cfe163facbc18168b38f57a403eb
6
+ metadata.gz: 71786966777a2ebcbbdf370bf436c8d5d983e710f0fca4f2f2c7e63ea8dab9fc51982b457a4cdfeeb3085cb4509260cd8646b15de374bd41b0ca114ae647d121
7
+ data.tar.gz: b03108695f1e78fae5c0ab4dc2da904b9af2409e93d4bb0529da78a1fa10f28e1f2548165890dc7710f35b364765559ecdcc60d2e5444f9035489fb5a737e831
@@ -1,5 +1,9 @@
1
1
  ## Change Log
2
2
 
3
+ ### v0.6.0 / 2017-07-23
4
+
5
+ - deps: upgrade rest-client to 2.x
6
+
3
7
  ### v0.5.0 / 2016-11-08
4
8
 
5
9
  - feat: add crc check for uploading(enabled by default) and downloading(disabled by default)
data/README.md CHANGED
@@ -1,75 +1,73 @@
1
- # Aliyun OSS SDK for Ruby
1
+ # Alibaba Cloud OSS SDK for Ruby
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/aliyun-sdk.svg)](https://badge.fury.io/rb/aliyun-sdk)
4
4
  [![Build Status](https://travis-ci.org/aliyun/aliyun-oss-ruby-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-ruby-sdk?branch=master)
5
5
  [![Coverage Status](https://coveralls.io/repos/aliyun/aliyun-oss-ruby-sdk/badge.svg?branch=master&service=github)](https://coveralls.io/github/aliyun/aliyun-oss-ruby-sdk?branch=master)
6
6
 
7
- -----
7
+ ## [README of Chinese](https://github.com/aliyun/aliyun-oss-ruby-sdk/blob/master/README-CN.md)
8
8
 
9
- Aliyun OSS SDK for Ruby是用于方便访问阿里云OSS(Object Storage Service)
10
- RESTful API的Ruby客户端程序。了解OSS的的更多信息请访问OSS官网:
11
- http://www.aliyun.com/product/oss
9
+ ## About
12
10
 
13
- ## 运行环境
11
+ Alibaba Cloud OSS SDK for Ruby is a Ruby client program for convenient access to Alibaba Cloud OSS (Object Storage Service)
12
+ RESTful APIs. For more information about OSS, visit [the OSS official website]( http://www.aliyun.com/product/oss).
14
13
 
15
- - Ruby版本 >= 1.9.3
16
- - 支持Ruby运行环境的Windows/Linux/OS X
14
+ ## Run environment
17
15
 
18
- 安装Ruby请参考:https://www.ruby-lang.org/zh_cn/downloads/
16
+ - Ruby ***2.0*** or above. For Ruby 1.9, please use v0.5.0.
17
+ - *Windows*, *Linux* or *OS X* system that supports Ruby.
19
18
 
20
- ## 快速开始
19
+ To learn how to install Ruby, refer to: [ruby-lang](https://www.ruby-lang.org/en/documentation/installation/).
21
20
 
22
- ### 开通OSS账号
21
+ ## Quick start
23
22
 
24
- 登录官网:http://www.aliyun.com/product/oss ,点击“立即开通”。按照提示
25
- 开通OSS服务。开通服务之后请在“管理控制台”中查看您的AccessKeyId和
26
- AccessKeySecret,在使用Aliyun OSS SDK时需要提供您的这两个信息。
23
+ ### Activate an OSS account
27
24
 
28
- ### 安装Aliyun OSS SDK for Ruby
25
+ Log onto [the official website](http://www.aliyun.com/product/oss) and click *Activate Now*. Follow the prompts
26
+ to activate OSS. After the service is activated, go to *Console* to view your `AccessKeyId` and
27
+ `AccessKeySecret`. These two information items are required when you use Alibaba Cloud OSS SDK.
28
+
29
+ ### Install Alibaba Cloud OSS SDK for Ruby
29
30
 
30
31
  gem install aliyun-sdk
31
32
 
32
- 并在你的程序中或者`irb`命令下包含:
33
+ Include the following in your project or 'irb' command:
33
34
 
34
35
  require 'aliyun/oss'
35
36
 
36
- **注意:**
37
+ **Note:**
37
38
 
38
- 1. SDK依赖的一些gem是本地扩展的形式,因此安装完Ruby之后还需要安装
39
- ruby-dev以支持编译本地扩展的gem
40
- 2. SDK依赖的处理XML的gem(nokogiri)要求环境中包含zlib
39
+ - Some gems on which the SDK depends are local extensions, and you need to install ruby-dev to compile locally
40
+ extended gems after you install Ruby.
41
+ - The environment for running the SDK-dependent gem (nokogiri) for processing XML must have the zlib library.
41
42
 
42
- Ubuntu为例,安装上述依赖的方法:
43
+ The following method is used to install the preceding dependencies taking *Ubuntu* as an example:
43
44
 
44
45
  sudo apt-get install ruby-dev
45
46
  sudo apt-get install zlib1g-dev
46
47
 
47
- 其他系统类似。
48
+ The practices for other systems are similar.
48
49
 
49
- ### 创建Client
50
+ ### Create a client
50
51
 
51
52
  client = Aliyun::OSS::Client.new(
52
53
  :endpoint => 'endpoint',
53
54
  :access_key_id => 'access_key_id',
54
55
  :access_key_secret => 'access_key_secret')
55
56
 
56
- 其中`endpoint`是OSS服务的地址,根据节点区域不同,这个地址可能不一样,例如
57
- 杭州节点的地址是:`http://oss-cn-hangzhou.aliyuncs.com`,其他节点的地址见:
58
- [节点列表][region-list]
57
+ In specific, the `endpoint` is the OSS service address. The address may vary based on different regions for the node. For example,
58
+ the address for a Hangzhou node is: `http://oss-cn-hangzhou.aliyuncs.com`. For addresses for other nodes, see: [Node List][region-list].
59
59
 
60
- `access_key_id`和`access_key_secret`是您的服务凭证,在官网的“管理控制
61
- 台”上面可以查看。**请妥善保管您的AccessKeySecret,泄露之后可能影响您的
62
- 数据安全**
60
+ The `access_key_id` and `access_key_secret` are credentials for your service. You can view them in `Console` on the official website. **Please keep your AccessKeySecret safe. Disclosing the AccessKeySecret may compromise your data security**.
63
61
 
64
- #### 使用用户绑定的域名作为endpoint
62
+ #### Use a bound domain as the endpoint
65
63
 
66
- OSS支持自定义域名绑定,允许用户将自己的域名指向阿里云OSS的服务地址
67
- CNAME),这样用户迁移到OSS上时应用内资源的路径可以不用修改。绑定的域
68
- 名指向OSS的一个bucket。绑定域名的操作只能在OSS控制台进行。更多关于自定
69
- 义域名绑定的内容请到官网了解:[OSS自定义域名绑定][custom-domain]
64
+ OSS supports binding a custom domain name and allows you to direct your domain name to the OSS service address
65
+ (CNAME) of Alibaba Cloud. In this way, you don't need to change the resource path in your app when migrating your data to the OSS. The bound domain name
66
+ points to a bucket in the OSS. The domain name binding operation can only be carried out in the OSS console. For more information about
67
+ binding a custom domain name, visit the official website: [Binding Custom Domain Names in OSS][custom-domain].
70
68
 
71
- 用户绑定了域名后,使用SDK时指定的endpoint可以使用标准的OSS服务地址,也
72
- 可以使用用户绑定的域名:
69
+ After you have bound a custom domain name, you can use the standard OSS service address as the specified endpoint of the OSS,
70
+ or use the bound domain name:
73
71
 
74
72
  client = Aliyun::OSS::Client.new(
75
73
  :endpoint => 'http://img.my-domain.com',
@@ -77,19 +75,19 @@ OSS支持自定义域名绑定,允许用户将自己的域名指向阿里云OS
77
75
  :access_key_secret => 'access_key_secret',
78
76
  :cname => true)
79
77
 
80
- 有以下几点需要注意:
78
+ **Note:**
81
79
 
82
- 1. 在Client初始化时必须指定:cnametrue
83
- 2. 自定义域名绑定了OSS的一个bucket,所以用这种方式创建的client不能进行
84
- list_buckets操作
85
- 3. {Aliyun::OSS::Client#get_bucket}时仍需要指定bucket名字,并且要与
86
- 域名所绑定的bucket名字相同
80
+ - You must set the `cname` to ***true*** when initializing the client.
81
+ - The custom domain name is bound to a bucket of the OSS, so the client created in this method does not support
82
+ List_buckets operations.
83
+ - You still need to specify the bucket name during the {Aliyun::OSS::Client#get_bucket} operation and the bucket name should be the same as that
84
+ bound to the domain name.
87
85
 
88
- #### 使用STS创建Client
86
+ #### Create a client using STS
89
87
 
90
- OSS支持用户使用STS进行访问,更多有关STS的内容,请参考 [阿里云STS][aliyun-sts]
91
- 在使用STS之前需要先向STS申请一个临时token,
92
- aliyun-sdk中包含了STSSDK,使用时只需要`require 'aliyun/sts'`即可:
88
+ OSS supports access via STS. For more information about STS, refer to [Alibaba Cloud STS][aliyun-sts].
89
+ Before using STS, you must apply for a temporary token from the STS.
90
+ Alibaba Cloud Ruby SDK contains the STS SDK, and you only need to `require 'aliyun/sts'` for usage:
93
91
 
94
92
  require 'aliyun/sts'
95
93
  sts = Aliyun::STS::Client.new(
@@ -104,71 +102,70 @@ aliyun-sdk中包含了STS的SDK,使用时只需要`require 'aliyun/sts'`即可
104
102
  :access_key_secret => token.access_key_secret,
105
103
  :sts_token => token.security_token)
106
104
 
107
- 注意使用STS时必须指定`:sts_token`参数。用户还可以通过`STS::Client`申请
108
- 带Policy的token,细节请参考[API文档][sdk-api]。
105
+ **Note:** the `:sts_token` parameter must be specified for using STS. You can also apply for a token with a policy through `STS::Client`, for details, refer to [API Documentation][sdk-api].
109
106
 
110
- ### 列出当前所有的Bucket
107
+ ### List all the current buckets
111
108
 
112
109
  buckets = client.list_buckets
113
110
  buckets.each{ |b| puts b.name }
114
111
 
115
- `list_buckets`返回的是一个迭代器,用户依次获取每个Bucket的信息。Bucket
116
- 对象的结构请查看API文档中的{Aliyun::OSS::Bucket}
112
+ The `list_buckets` command returns an iterator for you to get the information of each bucket in order. Bucket
113
+ For the object structure, see {Aliyun::OSS::Bucket} in the API documentation.
117
114
 
118
- ### 创建一个Bucket
115
+ ### Create a bucket
119
116
 
120
117
  bucket = client.create_bucket('my-bucket')
121
118
 
122
- ### 列出Bucket中所有的Object
119
+ ### List all the objects in a bucket
123
120
 
124
121
  bucket = client.get_bucket('my-bucket')
125
122
  objects = bucket.list_objects
126
123
  objects.each{ |o| puts o.key }
127
124
 
128
- `list_objects`返回的是一个迭代器,用户依次获取每个Object的信息。Object
129
- 对象的结构请查看API文档中的{Aliyun::OSS::Object}
125
+ The `list_objects` command returns an iterator for you to get the information of each object in order. Object
126
+ For the object structure, see {Aliyun::OSS::Object} in the API documentation.
130
127
 
131
- ### 在Bucket中创建一个Object
128
+ ### Create an object in the bucket
132
129
 
133
130
  bucket.put_object(object_key){ |stream| stream << 'hello world' }
134
131
 
135
- 用户也可以通过上传本地文件创建一个Object:
132
+ You can also create an object by uploading a local file:
136
133
 
137
134
  bucket.put_object(object_key, :file => local_file)
138
135
 
139
- ### 从Bucket中下载一个Object
136
+ ### Download an object from the bucket
140
137
 
141
138
  bucket.get_object(object_key){ |content| puts content }
142
139
 
143
- 用户也可以将Object下载到本地文件中:
140
+ You can also download the object to a local file:
144
141
 
145
142
  bucket.get_object(object_key, :file => local_file)
146
143
 
147
- ### 拷贝Object
144
+ ### Copy an object
148
145
 
149
146
  bucket.copy_object(from_key, to_key)
150
147
 
151
- ### 判断一个Object是否存在
148
+ ### Identify whether an object exists
152
149
 
153
150
  bucket.object_exists?(object_key)
154
151
 
155
- 更多Bucket的操作请参考API文档中的{Aliyun::OSS::Bucket}
152
+ For more operations on buckets, refer to {Aliyun::OSS::Bucket} in the API documentation.
156
153
 
157
- ## 模拟目录结构
154
+ ## Simulate the directory structure
158
155
 
159
- OSS是Object存储服务,本身不支持目录结构,所有的object都是“平”的。但是
160
- 用户可以通过设置objectkey"foo/bar/file"这样的形式来模拟目录结构。
161
- 假设现在有以下Objects:
156
+ OSS is a storage service for objects and does not support the directory structure. All objects are flatly structured. But
157
+ you can simulate the directory structure by setting the object key in the format "foo/bar/file".
158
+ Suppose there are several objects as follows:
162
159
 
163
160
  foo/x
164
161
  foo/bar/f1
165
162
  foo/bar/dir/file
166
163
  foo/hello/file
167
164
 
168
- 列出"foo/"目录下的所有文件就是以"foo/"prefix进行`list_objects`,但
169
- 是这样也会把"foo/bar/"下的所有object也列出来。为此需要用到delimiter
170
- 数,其含义是从prefix往后遇到第一个delimiter时停止,这中间的key作为
171
- Object的common prefix,包含在`list_objects`的结果中。
165
+ Listing all the objects under the "foo/" directory means to perform the *list_objects* operation with "foo/" as the prefix.
166
+ But this method will also list all the objects under "foo/bar/". That's why we need the delimiter parameter.
167
+ This parameter means to stop processing at the first delimiter after the prefix. The key during the process acts as
168
+ the common prefix of objects, objects with the prefix will be included in the *list_objects* result.
172
169
 
173
170
  objs = bucket.list_objects(:prefix => 'foo/', :delimiter => '/')
174
171
  objs.each do |i|
@@ -183,17 +180,17 @@ Object的common prefix,包含在`list_objects`的结果中。
183
180
  common prefix: foo/bar/
184
181
  common prefix: foo/hello/
185
182
 
186
- Common prefix让用户不需要遍历所有的object(可能数量巨大)而找出前缀,
187
- 在模拟目录结构时非常有用。
183
+ Common prefixes free you from traversing all the objects (the number of objects may be huge) to determine the prefix,
184
+ and is quite helpful for simulating the directory structure.
188
185
 
189
- ## 上传回调
186
+ ## Upload callback
190
187
 
191
- 在`put_object`和`resumable_upload`时可以指定一个`Callback`,这样在文件
192
- 成功上传到OSS之后,OSS会向用户提供的服务器地址发起一个HTTP POST请求,
193
- 以通知用户相应的事件发生了。用户可以在收到这个通知之后进行相应的动作,
194
- 例如更新数据库、统计行为等。更多有关上传回调的内容请参考[OSS上传回调][oss-callback]
188
+ You can specify a *callback* for `put_object` and `resumable_upload` so that after the file
189
+ is successfully uploaded to the OSS, the OSS will initiate an *HTTP POST* request to the server address you provided
190
+ to notify you that the corresponding event has occurred. You can perform desired actions after receiving the notification,
191
+ such as updating the database and making statistics. For more details about upload callback, refer to [OSS Upload Callback][oss-callback].
195
192
 
196
- 下面的例子将演示如何使用上传回调:
193
+ The example below demonstrates how to use the upload callback:
197
194
 
198
195
  callback = Aliyun::OSS::Callback.new(
199
196
  url: 'http://10.101.168.94:1234/callback',
@@ -207,31 +204,31 @@ Common prefix让用户不需要遍历所有的object(可能数量巨大)而
207
204
  puts "Callback failed: #{e.message}"
208
205
  end
209
206
 
210
- **注意**
207
+ **Note:**
211
208
 
212
- 1. callback的url**不能**包含query string,而应该在`:query`参数中指定
213
- 2. 可能出现文件上传成功,但是执行回调失败的情况,此时client会抛出
214
- `CallbackError`,用户如果要忽略此错误,需要显式接住这个异常。
215
- 3. 详细的例子可以参考[callback.rb](examples/aliyun/oss/callback.rb)
216
- 4. 接受回调的server可以参考[callback_server.rb](rails/aliyun_oss_callback_server.rb)
209
+ - The callback URL **must not** contain the query string which must be specified in the `:query` parameter.
210
+ - In the event that the file is successfully uploaded but callback execution fails, the client will throw
211
+ `CallbackError`. To ignore the error, you need to explicitly catch the exception.
212
+ - For detailed examples, refer to [callback.rb](examples/aliyun/oss/callback.rb).
213
+ - For servers that support callback, refer to [callback_server.rb](rails/aliyun_oss_callback_server.rb).
217
214
 
218
- ## 断点上传/下载
215
+ ## Resumable upload/download
219
216
 
220
- OSS支持大文件的存储,用户如果上传/下载大文件(Object)的时候中断了(网络
221
- 闪断、程序崩溃、机器断电等),重新上传/下载是件很费资源的事情。OSS支持
222
- Multipart的功能,可以在上传/下载时将大文件进行分片传输。Aliyun OSS SDK
223
- 基于此提供了断点上传/下载的功能。如果发生中断,可以从上次中断的地方继
224
- 续进行上传/下载。对于文件大小超过100MB的文件,都建议采用断点上传/下载
225
- 的方式进行。
217
+ OSS supports the storage of large objects. If the upload/download task of a large object is interrupted (due to network transient disconnections, program crashes, or machine power-off),
218
+ the re-upload/re-download is taxing on system resources. The OSS supports
219
+ multipart upload/download to divide a large object into multiple parts for upload/download. Alibaba Cloud OSS SDK
220
+ provides the resumable upload/download feature based on this principle. If an interruption occurs, you can resume the upload/download task
221
+ beginning with the interrupted part. ***Resumable upload/download is recommended for objects
222
+ larger than 100MB***.
226
223
 
227
- ### 断点上传
224
+ ### Resumable upload
228
225
 
229
226
  bucket.resumable_upload(object_key, local_file, :cpt_file => cpt_file)
230
227
 
231
- 其中`:cpt_file`指定保存上传中间状态的checkpoint文件所在的位置,如果用户
232
- 没有指定,SDK将为用户在`local_file`所在的目录生成一个
233
- `local_file.cpt`。上传中断后,只需要提供相同的cpt文件,上传将会从
234
- 中断的点继续上传。所以典型的上传代码是:
228
+ In specific, `:cpt_file` specifies the location of the checkpoint object which stores the intermediate state of the upload.
229
+ If no object is specified, the SDK will generate a
230
+ `local_file.cpt` in the directory of the `local_file`. After the upload interruption, you only need to provide the same cpt object for the upload task to resume from
231
+ the interrupted part. The typical upload code is:
235
232
 
236
233
  retry_times = 5
237
234
  retry_times.times do
@@ -242,21 +239,21 @@ Multipart的功能,可以在上传/下载时将大文件进行分片传输。A
242
239
  end
243
240
  end
244
241
 
245
- 注意:
242
+ **Notes:**
246
243
 
247
- 1. SDK会将上传的中间状态信息记录在cpt文件中,所以要确保用户对cpt文
248
- 件有写权限
249
- 2. cpt文件记录了上传的中间状态信息并自带了校验,用户不能去编辑它,如
250
- cpt文件损坏则上传无法继续。整个上传完成后cpt文件会被删除。
244
+ - The SDK records the upload intermediate states in the cpt object. Therefore, ensure that you have
245
+ write permission on the cpt object.
246
+ - The cpt object records the intermediate state information of the upload and has a self-checking function. You cannot edit the object.
247
+ Upload will fail if the cpt object is corrupted. When the upload is completed, the checkpoint file will be deleted.
251
248
 
252
- ### 断点下载
249
+ ### Resumable download
253
250
 
254
251
  bucket.resumable_download(object_key, local_file, :cpt_file => cpt_file)
255
252
 
256
- 其中`:cpt_file`指定保存下载中间状态的checkpoint文件所在的位置,如果用户
257
- 没有指定,SDK将为用户在`local_file`所在的目录生成一个
258
- `local_file.cpt`。下载中断后,只需要提供相同的cpt文件,下载将会从
259
- 中断的点继续下载。所以典型的下载代码是:
253
+ In specific, `:cpt_file` specifies the location of the checkpoint object which stores the intermediate state of the download.
254
+ If no object is specified, the SDK will generate a
255
+ `local_file.cpt` in the directory of the `local_file`. After the download interruption, you only need to provide the same cpt object for the download task to resume from
256
+ the interrupted part. The typical download code is:
260
257
 
261
258
  retry_times = 5
262
259
  retry_times.times do
@@ -267,55 +264,55 @@ Multipart的功能,可以在上传/下载时将大文件进行分片传输。A
267
264
  end
268
265
  end
269
266
 
270
- 注意:
267
+ **Notes:**
271
268
 
272
- 1. 在下载过程中,对于下载完成的每个分片,会在`local_file`所在的目录生
273
- 成一个`local_file.part.N`的临时文件。整个下载完成后这些文件会被删除。
274
- 用户不能去编辑或删除part文件,否则下载不能继续。
275
- 2. SDK会将下载的中间状态信息记录在cpt文件中,所以要确保用户对cpt文
276
- 件有写权限
277
- 3. cpt文件记录了下载的中间状态信息并自带了校验,用户不能去编辑它,如
278
- cpt文件损坏则下载无法继续。整个下载完成后cpt文件会被删除。
269
+ - During the download process, a temporary object of `local_file.part.N` will be generated in the directory of the `local_file`
270
+ for each part downloaded. When the download is completed, the objects will be deleted.
271
+ You cannot edit or delete the part objects, otherwise the download will not proceed.
272
+ - The SDK records the download intermediate states in the cpt object; therefore, ensure that you have
273
+ write permission on the cpt object.
274
+ - The cpt object records the intermediate state information of the download and has a self-checking function. You cannot edit the object.
275
+ Download will fail if the cpt object is corrupted. When the download is completed, the `checkpoint` object will be deleted.
279
276
 
280
277
 
281
- ## 可追加的文件
278
+ # Appendable object
282
279
 
283
- 阿里云OSS中的Object分为两种类型:NormalAppendable
280
+ Objects in Alibaba Cloud OSS can be divided into two types: Normal and Appendable.
284
281
 
285
- - 对于Normal Object,每次上传都是作为一个整体,如果一个Object已存在,
286
- 两次上传相同key的Object将会覆盖原有的Object
287
- - 对于Appendable Object,第一次通过`append_object`创建它,后续的
288
- `append_object`不会覆盖原有的内容,而是在Object末尾追加内容
289
- - 不能向Normal Object追加内容
290
- - 不能拷贝一个Appendable Object
282
+ - A normal object functions as a whole for every upload. If an object already exists,
283
+ the later uploaded object will overwrite the previous object with the same key.
284
+ - An appendable object is created through `append_object` for the first time. The later uploaded
285
+ object through `append_object` will not overwrite the previous one, but will append content to the end of the object.
286
+ - You cannot append content to a normal object.
287
+ - You cannot copy an appendable object.
291
288
 
292
- ### 创建一个Appendable Object
289
+ ### Create an appendable object
293
290
 
294
291
  bucket.append_object(object_key, 0){ |stream| stream << "hello world" }
295
292
 
296
- 第二个参数是追加的位置,对一个Object第一次追加时,这个参数为0。后续的
297
- 追加这个参数要求是追加前Object的长度。
293
+ The second parameter indicates the position to append the content. This parameter is ***0*** for the first append to the object. In later
294
+ append operations, the value of this parameter is the length of the object before the append.
298
295
 
299
- 当然,也可以从文件中读取追加的内容:
296
+ Of course, you can also read the appended content from the object:
300
297
 
301
298
  bucket.append_object(object_key, 0, :file => local_file)
302
299
 
303
- ### 向Object追加内容
300
+ ### Append content to the object
304
301
 
305
302
  pos = bucket.get_object(object_key).size
306
303
  next_pos = bucket.append_object(object_key, pos, :file => local_file)
307
304
 
308
- 程序第一次追加时,可以通过{Aliyun::OSS::Bucket#get_object}获取文件的长度,
309
- 后续追加时,可以根据{Aliyun::OSS::Bucket#append_object}返回的下次追加长度。
305
+ During the first append, you can use {Aliyun::OSS::Bucket#get_object} to get the object length.
306
+ For later append operations, you can refer to the response of {Aliyun::OSS::Bucket#append_object} to determine the length value for next append.
310
307
 
311
- 注意:如果并发地`append_object`,`next_pos`并不总是对的。
308
+ ***Note:*** Concurrent `append_object` and `next_pos` operations do not always produce correct results.
312
309
 
313
- ## Object meta信息
310
+ ## Object meta information
314
311
 
315
- 在上传Object时,除了Object内容,OSS还允许用户为Object设置一些"meta信息
316
- ",这些meta信息是一个个的Key-Value对,用于标识Object特有的属性信息。这
317
- meta信息会跟Object一起存储,并在`get_object`和`get_object`时返
318
- 回给用户。
312
+ Besides the object content, the OSS also allows you to set some *meta information* for the object during object uploading.
313
+ The meta information is a key-value pair to identify the specific attributes of the object. The
314
+ meta information will be stored together with the object and returned to users in `get_object` and `get_object_meta`
315
+ operations.
319
316
 
320
317
  bucket.put_object(object_key, :file => local_file,
321
318
  :metas => {
@@ -325,36 +322,36 @@ Multipart的功能,可以在上传/下载时将大文件进行分片传输。A
325
322
  obj = bucket.get_object(object_key, :file => localfile)
326
323
  puts obj.metas
327
324
 
328
- 关于meta信息有以下几点需要注意:
325
+ **Note:**
329
326
 
330
- 1. meta信息的keyvalue都只能是简单的ASCII非换行字符,并且总的大小不能超过8KB
331
- 2. Copy object时默认将拷贝源object的meta信息,如果用户不希望这么做,需要
332
- 显式地将`:meta_directive`设置成{Aliyun::OSS::MetaDirective::REPLACE}
327
+ - The key and value of the meta information can only be simple ASCII non-newline characters and the total size must not exceed ***8KB***.
328
+ - In the copy object operation, the meta information of the source object will be copied by default. If you don't want this, explicitly set the
329
+ `:meta_directive` to {Aliyun::OSS::MetaDirective::REPLACE}.
333
330
 
334
- ## 权限控制
331
+ ## Permission control
335
332
 
336
- OSS允许用户对Bucket和Object分别设置访问权限,方便用户控制自己的资源可
337
- 以被如何访问。对于Bucket,有三种访问权限:
333
+ OSS allows you to set access permissions for buckets and objects respectively, so that you can conveniently control
334
+ external access to your resources. A bucket is enabled with three types of access permissions:
338
335
 
339
- - public-read-write 允许匿名用户向该Bucket中创建/获取/删除Object
340
- - public-read 允许匿名用户获取该Bucket中的Object
341
- - private 不允许匿名访问,所有的访问都要经过签名
336
+ - public-read-write: Anonymous users are allowed to create/retrieve/delete objects in the bucket.
337
+ - public-read: Anonymous users are allowed to retrieve objects in the bucket.
338
+ - private: Anonymous users are not allowed to access the bucket. Signature is required for all accesses.
342
339
 
343
- 创建Bucket时,默认是private权限。之后用户可以通过`bucket.acl=`来设置
344
- Bucket的权限。
340
+ When a bucket is created, the private permission applies by default. You can use 'bucket.acl=' to set
341
+ the ACL of the bucket.
345
342
 
346
343
  bucket.acl = Aliyun::OSS::ACL::PUBLIC_READ
347
344
  puts bucket.acl # public-read
348
345
 
349
- 对于Object,有四种访问权限:
346
+ An object is enabled with four types of access permissions:
350
347
 
351
- - default 继承所属的Bucket的访问权限,即与所属Bucket的权限值一样
352
- - public-read-write 允许匿名用户读写该Object
353
- - public-read 允许匿名用户读该Object
354
- - private 不允许匿名访问,所有的访问都要经过签名
348
+ - default: The object inherits the access permissions of the bucket it belongs to, that is, the access permission of the object is the same as that of the bucket where the object is stored.
349
+ - public-read-write: Anonymous users are allowed to read/write the object.
350
+ - public-read: Anonymous users are allowed to read the object.
351
+ - private: Anonymous users are not allowed to access the object. Signature is required for all accesses.
355
352
 
356
- 创建Object时,默认为default权限。之后用户可以通过
357
- `bucket.set_object_acl`来设置Object的权限。
353
+ When an object is created, the default permission applies by default. You can use
354
+ 'bucket.set_object_acl' to configure the ACL of the object.
358
355
 
359
356
  acl = bucket.get_object_acl(object_key)
360
357
  puts acl # default
@@ -362,28 +359,28 @@ Bucket的权限。
362
359
  acl = bucket.get_object_acl(object_key)
363
360
  puts acl # public-read
364
361
 
365
- 需要注意的是:
362
+ **Notes:**
366
363
 
367
- 1. 如果设置了Object的权限,则访问该Object时进行权限认证时会优先判断
368
- Object的权限,而Bucket的权限设置会被忽略。
369
- 2. 允许匿名访问时(设置了public-read或者public-read-write权限),用户
370
- 可以直接通过浏览器访问,例如:
364
+ - If an object is configured with an ACL policy, the object ACL takes priority during permission authentication
365
+ when the object is accessed. The bucket ACL will be ignored.
366
+ - If anonymous access is allowed (public-read or public-read-write is configured for the object), you
367
+ can directly access the object using a browser. For example,
371
368
 
372
369
  http://bucket-name.oss-cn-hangzhou.aliyuncs.com/object.jpg
373
370
 
374
- 3. 访问具有public权限的Bucket/Object时,也可以通过创建匿名的Client来进行:
371
+ - A bucket or an object with the public permission can be accessed by an anonymous client which is created with the following code:
375
372
 
376
- # 不填access_key_idaccess_key_secret,将创建匿名Client,只能访问
377
- # 具有public权限的Bucket/Object
373
+ # If access_key_id and access_key_secret are not specified, an anonymous client will be created. The client can only access
374
+ # the buckets and objects with the public permission.
378
375
  client = Client.new(:endpoint => 'oss-cn-hangzhou.aliyuncs.com')
379
376
  bucket = client.get_bucket('public-bucket')
380
377
  obj = bucket.get_object('public-object', :file => local_file)
381
378
 
382
- ## 运行examples
379
+ ## Run examples
383
380
 
384
- SDKexamples/目录下有一些展示SDK功能的示例程序,用户稍加配置就可以直
385
- 接运行。examples需要的权限信息和bucket信息从用户`HOME`目录下的配置文件
386
- `~/.oss.yml`中读取,其中应该包含以下字段(**注意冒号后面需要有一个空格**):
381
+ Some example projects are provided in the examples/ directory of the SDK to demonstrate the SDK features. You can run the examples
382
+ after some configuration. The permission information and the bucket information required by the examples are available in the
383
+ `~/.oss.yml` configuration file under the *HOME* directory. The information should include the following fields (**Note the space after the colon**):
387
384
 
388
385
  endpoint: oss-cn-hangzhou.aliyuncs.com
389
386
  cname: false
@@ -391,11 +388,11 @@ SDK的examples/目录下有一些展示SDK功能的示例程序,用户稍加
391
388
  access_key_secret: <ACCESS KEY SECRET>
392
389
  bucket: <BUCKET NAME>
393
390
 
394
- 用户需要创建(如果不存在)或者修改其中的内容,然后运行:
391
+ You need to create (if not in existence) or modify the content and run the example project:
395
392
 
396
393
  ruby examples/aliyun/oss/bucket.rb
397
394
 
398
- ## 运行测试
395
+ ## Run test
399
396
 
400
397
  ```bash
401
398
  bundle exec rake spec
@@ -408,12 +405,16 @@ export RUBY_SDK_OSS_BUCKET=bucket-name
408
405
  bundle exec rake test
409
406
  ```
410
407
 
411
- ## 更多
408
+ ## License
409
+
410
+ - MIT
412
411
 
413
- 更多文档请查看:
412
+ ## More
414
413
 
415
- - 阿里云官网文档:http://help.aliyun.com/product/8314910_oss.html
416
- - OSS官网SDK文档:https://help.aliyun.com/document_detail/oss/sdk/ruby-sdk/install.html
414
+ For more documentation, see:
415
+
416
+ - Alibaba Cloud OSS Ruby SDK [documentation](https://help.aliyun.com/document_detail/oss/sdk/ruby-sdk/install.html).
417
+ - Alibaba Cloud OSS [documentation](http://help.aliyun.com/product/8314910_oss.html).
417
418
 
418
419
 
419
420
  [region-list]: https://help.aliyun.com/document_detail/oss/user_guide/endpoint_region.html
@@ -421,3 +422,4 @@ bundle exec rake test
421
422
  [aliyun-sts]: https://help.aliyun.com/document_detail/ram/intro/concepts.html
422
423
  [sdk-api]: http://www.rubydoc.info/gems/aliyun-sdk/
423
424
  [oss-callback]: https://help.aliyun.com/document_detail/oss/user_guide/upload_object/upload_callback.html
425
+