Module: Qiniu::S3
- Defined in:
- lib/qiniu/s3.rb,
lib/qiniu/s3/io.rb,
lib/qiniu/s3/rs.rb,
lib/qiniu/s3/log.rb,
lib/qiniu/s3/auth.rb,
lib/qiniu/s3/image.rb,
lib/qiniu/s3/utils.rb,
lib/qiniu/s3/config.rb,
lib/qiniu/s3/version.rb,
lib/qiniu/s3/exceptions.rb
Defined Under Namespace
Modules: Auth, Config, IO, Image, Log, RS, Utils
Classes: Exception, InvalidArgsError, MissingAccessToken, MissingArgsError, MissingConfError, MissingRefreshToken, MissingUsernameOrPassword, NoSuchFileError, RequestFailed, ResponseError
Constant Summary
collapse
- StatusOK =
200
- VERSION =
"0.1.2"
Class Method Summary
collapse
-
.batch(command, bucket, keys) ⇒ Object
-
.batch_delete(bucket, keys) ⇒ Object
-
.batch_download(bucket, keys) ⇒ Object
-
.batch_get(bucket, keys) ⇒ Object
-
.batch_stat(bucket, keys) ⇒ Object
-
.delete(bucket, key) ⇒ Object
-
.download(bucket, key, save_as = nil, expires_in = nil, version = nil) ⇒ Object
-
.drop(bucket) ⇒ Object
-
.establish_connection!(opts = {}) ⇒ Object
-
.get(bucket, key, save_as = nil, expires_in = nil, version = nil) ⇒ Object
-
.image_info(url) ⇒ Object
-
.image_preview_url(url, spec) ⇒ Object
-
.login!(user, pwd) ⇒ Object
-
.publish(domain, bucket) ⇒ Object
-
.put_auth(expires_in = nil, callback_url = nil) ⇒ Object
-
.stat(bucket, key) ⇒ Object
-
.unpublish(domain) ⇒ Object
-
.upload(url, local_file, bucket = '', key = '', mime_type = '', custom_meta = '', callback_params = {}) ⇒ Object
Class Method Details
.batch(command, bucket, keys) ⇒ Object
59
60
61
62
|
# File 'lib/qiniu/s3.rb', line 59
def batch(command, bucket, keys)
code, data = RS.batch(command, bucket, keys)
code == StatusOK ? data : false
end
|
.batch_delete(bucket, keys) ⇒ Object
82
83
84
85
|
# File 'lib/qiniu/s3.rb', line 82
def batch_delete(bucket, keys)
code, data = RS.batch_delete(bucket, keys)
code == StatusOK ? data : false
end
|
.batch_download(bucket, keys) ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/qiniu/s3.rb', line 74
def batch_download(bucket, keys)
code, data = RS.batch_get(bucket, keys)
return false unless code == StatusOK
links = []
data.each { |e| links << e["data"]["url"] }
links
end
|
.batch_get(bucket, keys) ⇒ Object
69
70
71
72
|
# File 'lib/qiniu/s3.rb', line 69
def batch_get(bucket, keys)
code, data = RS.batch_get(bucket, keys)
code == StatusOK ? data : false
end
|
.batch_stat(bucket, keys) ⇒ Object
64
65
66
67
|
# File 'lib/qiniu/s3.rb', line 64
def batch_stat(bucket, keys)
code, data = RS.batch_stat(bucket, keys)
code == StatusOK ? data : false
end
|
.delete(bucket, key) ⇒ Object
54
55
56
57
|
# File 'lib/qiniu/s3.rb', line 54
def delete(bucket, key)
code, data = RS.delete(bucket, key)
code == StatusOK
end
|
.download(bucket, key, save_as = nil, expires_in = nil, version = nil) ⇒ Object
49
50
51
52
|
# File 'lib/qiniu/s3.rb', line 49
def download(bucket, key, save_as = nil, expires_in = nil, version = nil)
code, data = RS.get(bucket, key, save_as, expires_in, version)
code == StatusOK ? data["url"] : false
end
|
.drop(bucket) ⇒ Object
97
98
99
100
|
# File 'lib/qiniu/s3.rb', line 97
def drop(bucket)
code, data = RS.drop(bucket)
code == StatusOK
end
|
.establish_connection!(opts = {}) ⇒ Object
.get(bucket, key, save_as = nil, expires_in = nil, version = nil) ⇒ Object
44
45
46
47
|
# File 'lib/qiniu/s3.rb', line 44
def get(bucket, key, save_as = nil, expires_in = nil, version = nil)
code, data = RS.get(bucket, key, save_as, expires_in, version)
code == StatusOK ? data : false
end
|
.image_info(url) ⇒ Object
102
103
104
105
|
# File 'lib/qiniu/s3.rb', line 102
def image_info(url)
code, data = Image.info(url)
code == StatusOK ? data : false
end
|
.image_preview_url(url, spec) ⇒ Object
107
108
109
|
# File 'lib/qiniu/s3.rb', line 107
def image_preview_url(url, spec)
Image.preivew_url(url, spec)
end
|
.login!(user, pwd) ⇒ Object
.publish(domain, bucket) ⇒ Object
87
88
89
90
|
# File 'lib/qiniu/s3.rb', line 87
def publish(domain, bucket)
code, data = RS.publish(domain, bucket)
code == StatusOK
end
|
.put_auth(expires_in = nil, callback_url = nil) ⇒ Object
29
30
31
32
|
# File 'lib/qiniu/s3.rb', line 29
def put_auth(expires_in = nil, callback_url = nil)
code, data = IO.put_auth(expires_in, callback_url)
code == StatusOK ? data["url"] : false
end
|
.stat(bucket, key) ⇒ Object
39
40
41
42
|
# File 'lib/qiniu/s3.rb', line 39
def stat(bucket, key)
code, data = RS.stat(bucket, key)
code == StatusOK ? data : false
end
|
.unpublish(domain) ⇒ Object
92
93
94
95
|
# File 'lib/qiniu/s3.rb', line 92
def unpublish(domain)
code, data = RS.unpublish(domain)
code == StatusOK
end
|
.upload(url, local_file, bucket = '', key = '', mime_type = '', custom_meta = '', callback_params = {}) ⇒ Object
34
35
36
37
|
# File 'lib/qiniu/s3.rb', line 34
def upload(url, local_file, bucket = '', key = '', mime_type = '', custom_meta = '', callback_params = {})
code, data = IO.put_file(url, local_file, bucket, key, mime_type, custom_meta, callback_params)
code == StatusOK
end
|