From 9c1474cfcd6243b9309f0e0f8d5fde21a1bc9fb9 Mon Sep 17 00:00:00 2001 From: He Guimin Date: Mon, 3 Dec 2018 16:38:08 +0800 Subject: [PATCH] fix param expires format bug --- .gitignore | 2 ++ README.md | 5 +++-- lib/fog/aliyun/models/storage/file.rb | 3 +++ lib/fog/aliyun/models/storage/files.rb | 2 ++ lib/fog/aliyun/requests/storage/get_object_http_url.rb | 2 +- lib/fog/aliyun/requests/storage/get_object_https_url.rb | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 018f7ff..8a4612e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.idea +.idea/* *.gem *.rbc .bundle diff --git a/README.md b/README.md index 150ead4..ba5db30 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,10 @@ opt = { conn = Fog::Storage.new(opt) ``` **-> Note:** `:aliyun_region_id` is optional and default to "cn-hangzhou". + **-> Note:** `:aliyun_oss_endpoint` is optional. If it is not specified, it will be generated automatically by `:aliyun_region_id`. -Its basic format is "oss-.aliyuncs.com" and with default schema "http" and default port "80". -If you want to use https or 443 port, you can use a format "://oss-.aliyuncs.com:". +Its basic format is `oss-.aliyuncs.com` and with default schema "http" and default port "80". +If you want to use https or 443 port, you can use a format `://oss-.aliyuncs.com:`. ## Fog::Aliyun Abstractions diff --git a/lib/fog/aliyun/models/storage/file.rb b/lib/fog/aliyun/models/storage/file.rb index 7e63e25..1d9dd76 100644 --- a/lib/fog/aliyun/models/storage/file.rb +++ b/lib/fog/aliyun/models/storage/file.rb @@ -87,6 +87,9 @@ def public=(new_public) # @return [String] url # def url(expires, options = {}) + + expires = expires.nil? ? 0 : expires.to_i + requires :directory, :key object = if directory.key == '' key diff --git a/lib/fog/aliyun/models/storage/files.rb b/lib/fog/aliyun/models/storage/files.rb index f8cca49..d2d06e7 100644 --- a/lib/fog/aliyun/models/storage/files.rb +++ b/lib/fog/aliyun/models/storage/files.rb @@ -133,6 +133,7 @@ def get_http_url(key, expires, options = {}) else directory.key + '/' + key end + expires = expires.nil? ? 0 : expires.to_i service.get_object_http_url_public(object, expires, options) end @@ -143,6 +144,7 @@ def get_https_url(key, expires, options = {}) else directory.key + '/' + key end + expires = expires.nil? ? 0 : expires.to_i service.get_object_https_url_public(object, expires, options) end diff --git a/lib/fog/aliyun/requests/storage/get_object_http_url.rb b/lib/fog/aliyun/requests/storage/get_object_http_url.rb index 7fef702..12a9b70 100644 --- a/lib/fog/aliyun/requests/storage/get_object_http_url.rb +++ b/lib/fog/aliyun/requests/storage/get_object_http_url.rb @@ -9,7 +9,7 @@ class Real # ==== Parameters # * container<~String> - Name of container containing object # * object<~String> - Name of object to get expiring url for - # * expires<~Time> - An expiry time for this url + # * expires<~Integer> - An expiry time for this url # # ==== Returns # * response<~Excon::Response>: diff --git a/lib/fog/aliyun/requests/storage/get_object_https_url.rb b/lib/fog/aliyun/requests/storage/get_object_https_url.rb index 3ff7f5b..e1a4ae8 100644 --- a/lib/fog/aliyun/requests/storage/get_object_https_url.rb +++ b/lib/fog/aliyun/requests/storage/get_object_https_url.rb @@ -9,7 +9,7 @@ class Real # ==== Parameters # * container<~String> - Name of container containing object # * object<~String> - Name of object to get expiring url for - # * expires<~Time> - An expiry time for this url + # * expires<~Integer> - An expiry time for this url # # ==== Returns # * response<~Excon::Response>: