aliyun-sdk 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/aliyun/oss/bucket.rb +4 -4
- data/lib/aliyun/oss/client.rb +4 -0
- data/lib/aliyun/oss/config.rb +2 -1
- data/lib/aliyun/oss/http.rb +12 -2
- data/lib/aliyun/oss/multipart.rb +17 -2
- data/lib/aliyun/oss/upload.rb +1 -1
- data/lib/aliyun/oss/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a175798738ab2c2b9d5769d915913dbc7e025d4
|
4
|
+
data.tar.gz: af6c15c360539b23b596c93221660d44453d7349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ac5dd1199cef681699ef6ba6e7ed24fbc5c4a34e35a056c809a8eadb1cc0b76346b4e206d2cf8b1742d489de206349b6b5d4a5a53c0f0c4da6f05b66ec759f
|
7
|
+
data.tar.gz: 9b33d6da0bb5e48c70a353fa3babb202654d0ea4fd2e498ca16692bf7aad59124693057a5d90623f934f4a8fd7e78bca6aed81c33b91e1dbf27221fbd32c3206
|
data/CHANGELOG.md
CHANGED
data/lib/aliyun/oss/bucket.rb
CHANGED
@@ -412,8 +412,8 @@ module Aliyun
|
|
412
412
|
# 义的属性,它们会和object一起存储,在{#get_object}的时候会
|
413
413
|
# 返回这些meta。属性的key不区分大小写。例如:{ 'year' => '2015' }
|
414
414
|
# @option opts [Integer] :part_size 设置分片上传时每个分片的大小,
|
415
|
-
# 默认为
|
416
|
-
# 分片的大小,则每个分片的大小会大于
|
415
|
+
# 默认为10 MB。断点上传最多允许10000个分片,如果文件大于10000个
|
416
|
+
# 分片的大小,则每个分片的大小会大于10MB。
|
417
417
|
# @option opts [String] :cpt_file 断点续传的checkpoint文件,如果
|
418
418
|
# 指定的cpt文件不存在,则会在file所在目录创建一个默认的cpt文件,
|
419
419
|
# 命名方式为:file.cpt,其中file是用户要上传的文件。在上传的过
|
@@ -459,8 +459,8 @@ module Aliyun
|
|
459
459
|
# @param file [String] 本地文件的路径
|
460
460
|
# @param opts [Hash] 下载文件的可选项
|
461
461
|
# @option opts [Integer] :part_size 设置分片上传时每个分片的大小,
|
462
|
-
# 默认为
|
463
|
-
# 则每个分片的大小会大于
|
462
|
+
# 默认为10 MB。断点下载最多允许100个分片,如果文件大于100个分片,
|
463
|
+
# 则每个分片的大小会大于10 MB
|
464
464
|
# @option opts [String] :cpt_file 断点续传的checkpoint文件,如果
|
465
465
|
# 指定的cpt文件不存在,则会在file所在目录创建一个默认的cpt文件,
|
466
466
|
# 命名方式为:file.cpt,其中file是用户要下载的文件名。在下载的过
|
data/lib/aliyun/oss/client.rb
CHANGED
@@ -30,6 +30,10 @@ module Aliyun
|
|
30
30
|
# KEY SECRET,如果不填则会尝试匿名访问
|
31
31
|
# @option opts [Boolean] :cname [可选] 指定endpoint是否是用户绑
|
32
32
|
# 定的域名
|
33
|
+
# @option opts [Fixnum] :open_timeout [可选] 指定建立连接的超时
|
34
|
+
# 时间,默认为10秒
|
35
|
+
# @option opts [Fixnum] :read_timeout [可选] 指定等待响应的超时
|
36
|
+
# 时间,默认为120秒
|
33
37
|
# @example 标准endpoint
|
34
38
|
# oss-cn-hangzhou.aliyuncs.com
|
35
39
|
# oss-cn-beijing.aliyuncs.com
|
data/lib/aliyun/oss/config.rb
CHANGED
data/lib/aliyun/oss/http.rb
CHANGED
@@ -32,6 +32,8 @@ module Aliyun
|
|
32
32
|
class HTTP
|
33
33
|
|
34
34
|
DEFAULT_CONTENT_TYPE = 'application/octet-stream'
|
35
|
+
OPEN_TIMEOUT = 10
|
36
|
+
READ_TIMEOUT = 120
|
35
37
|
|
36
38
|
##
|
37
39
|
# A stream implementation
|
@@ -64,7 +66,13 @@ module Aliyun
|
|
64
66
|
outbuf << ret
|
65
67
|
end
|
66
68
|
|
67
|
-
|
69
|
+
# Conform to IO#read(length[, outbuf]):
|
70
|
+
# At end of file, it returns nil or "" depend on
|
71
|
+
# length. ios.read() and ios.read(nil) returns
|
72
|
+
# "". ios.read(positive-integer) returns nil.
|
73
|
+
return nil if ret.empty? && !bytes.nil? && bytes > 0
|
74
|
+
|
75
|
+
ret
|
68
76
|
end
|
69
77
|
|
70
78
|
def write(chunk)
|
@@ -231,7 +239,9 @@ module Aliyun
|
|
231
239
|
:url => get_request_url(bucket, object),
|
232
240
|
:headers => headers,
|
233
241
|
:payload => http_options[:body],
|
234
|
-
:block_response =>
|
242
|
+
:block_response => block_response,
|
243
|
+
:open_timeout => @config.open_timeout || OPEN_TIMEOUT,
|
244
|
+
:timeout => @config.read_timeout || READ_TIMEOUT
|
235
245
|
) do |response, request, result, &blk|
|
236
246
|
|
237
247
|
if response.code >= 300
|
data/lib/aliyun/oss/multipart.rb
CHANGED
@@ -20,16 +20,31 @@ module Aliyun
|
|
20
20
|
|
21
21
|
attrs :id, :object, :bucket, :creation_time, :options
|
22
22
|
|
23
|
+
def initialize(opts = {})
|
24
|
+
super(opts)
|
25
|
+
|
26
|
+
@mutex = Mutex.new
|
27
|
+
end
|
28
|
+
|
23
29
|
private
|
24
30
|
# Persist transaction states to file
|
25
31
|
def write_checkpoint(states, file)
|
26
32
|
md5= Util.get_content_md5(states.to_json)
|
27
|
-
|
33
|
+
|
34
|
+
@mutex.synchronize {
|
35
|
+
File.open(file, 'w') {
|
36
|
+
|f| f.write(states.merge(md5: md5).to_json)
|
37
|
+
}
|
38
|
+
}
|
28
39
|
end
|
29
40
|
|
30
41
|
# Load transaction states from file
|
31
42
|
def load_checkpoint(file)
|
32
|
-
states =
|
43
|
+
states = {}
|
44
|
+
|
45
|
+
@mutex.synchronize {
|
46
|
+
states = JSON.load(File.read(file))
|
47
|
+
}
|
33
48
|
states.symbolize_keys!
|
34
49
|
md5 = states.delete(:md5)
|
35
50
|
|
data/lib/aliyun/oss/upload.rb
CHANGED
data/lib/aliyun/oss/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyun-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tianlong Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|