Class: Qiniu::RS::UploadToken
- Inherits:
-
AccessToken
- Object
- AccessToken
- Qiniu::RS::UploadToken
- Includes:
- Utils
- Defined in:
- lib/qiniu/tokens/upload_token.rb
Instance Attribute Summary collapse
-
#async_options ⇒ Object
Returns the value of attribute async_options.
-
#callback_body ⇒ Object
Returns the value of attribute callback_body.
-
#callback_body_type ⇒ Object
Returns the value of attribute callback_body_type.
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#escape ⇒ Object
Returns the value of attribute escape.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#return_body ⇒ Object
Returns the value of attribute return_body.
-
#return_url ⇒ Object
Returns the value of attribute return_url.
-
#scope ⇒ Object
Returns the value of attribute scope.
Attributes inherited from AccessToken
Instance Method Summary collapse
- #generate_signature ⇒ Object
- #generate_token ⇒ Object
-
#initialize(opts = {}) ⇒ UploadToken
constructor
A new instance of UploadToken.
Methods included from Utils
#crc32checksum, #debug, #encode_entry_uri, #generate_qbox_signature, #generate_query_string, #http_request, #is_response_ok?, #response_error, #safe_json_parse, #send_request_with, #upload_multipart_data, #urlsafe_base64_decode, #urlsafe_base64_encode
Methods inherited from AccessToken
Constructor Details
#initialize(opts = {}) ⇒ UploadToken
Returns a new instance of UploadToken.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/qiniu/tokens/upload_token.rb', line 15 def initialize(opts = {}) @scope = opts[:scope] @expires_in = opts[:expires_in] || 3600 @callback_url = opts[:callback_url] @callback_body = opts[:callback_body] @callback_body_type = opts[:callback_body_type] @customer = opts[:customer] @escape = opts[:escape] @async_options = opts[:async_options] @return_body = opts[:return_body] @return_url = opts[:return_url] end |
Instance Attribute Details
#async_options ⇒ Object
Returns the value of attribute async_options.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def @async_options end |
#callback_body ⇒ Object
Returns the value of attribute callback_body.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def callback_body @callback_body end |
#callback_body_type ⇒ Object
Returns the value of attribute callback_body_type.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def callback_body_type @callback_body_type end |
#callback_url ⇒ Object
Returns the value of attribute callback_url.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def callback_url @callback_url end |
#customer ⇒ Object
Returns the value of attribute customer.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def customer @customer end |
#escape ⇒ Object
Returns the value of attribute escape.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def escape @escape end |
#expires_in ⇒ Object
Returns the value of attribute expires_in.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def expires_in @expires_in end |
#return_body ⇒ Object
Returns the value of attribute return_body.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def return_body @return_body end |
#return_url ⇒ Object
Returns the value of attribute return_url.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def return_url @return_url end |
#scope ⇒ Object
Returns the value of attribute scope.
13 14 15 |
# File 'lib/qiniu/tokens/upload_token.rb', line 13 def scope @scope end |
Instance Method Details
#generate_signature ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/qiniu/tokens/upload_token.rb', line 28 def generate_signature params = {:scope => @scope, :deadline => Time.now.to_i + @expires_in} params[:callbackUrl] = @callback_url if !@callback_url.nil? && !@callback_url.empty? params[:callbackBody] = @callback_body if !@callback_body.nil? && !@callback_body.empty? params[:callbackBodyType] = @callback_body_type if !@callback_body_type.nil? && !@callback_body_type.empty? params[:customer] = @customer if !@customer.nil? && !@customer.empty? params[:escape] = 1 if @escape == 1 || @escape == true params[:asyncOps] = @async_options if !@async_options.nil? && !@async_options.empty? params[:returnBody] = @return_body if !@return_body.nil? && !@return_body.empty? params[:returnUrl] = @return_url if !@return_url.nil? && !@return_url.empty? Utils.urlsafe_base64_encode(params.to_json) end |
#generate_token ⇒ Object
41 42 43 44 45 |
# File 'lib/qiniu/tokens/upload_token.rb', line 41 def generate_token signature = generate_signature encoded_digest = generate_encoded_digest(signature) %Q(#{@access_key}:#{encoded_digest}:#{signature}) end |