Class: Aliyun::OSS::Callback
- Inherits:
-
Common::Struct::Base
- Object
- Common::Struct::Base
- Aliyun::OSS::Callback
- Includes:
- Common::Logging
- Defined in:
- lib/aliyun/oss/struct.rb
Overview
Callback represents a HTTP call made by OSS to user’s application server after an event happens, such as an object is successfully uploaded to OSS. See: https://help.aliyun.com/document_detail/oss/api-reference/object/Callback.html Attributes:
-
url [String] the URL WITHOUT the query string
-
query [Hash] the query to generate query string
-
body [String] the body of the request
-
content_type [String] the Content-Type of the request
-
host [String] the Host in HTTP header for this request
Constant Summary
Constants included from Common::Logging
Common::Logging::MAX_NUM_LOG, Common::Logging::ROTATE_SIZE
Instance Method Summary collapse
Methods included from Common::Logging
#logger, set_log_file, set_log_level
Methods inherited from Common::Struct::Base
Methods included from Common::Struct::Base::AttrHelper
Constructor Details
This class inherits a constructor from Aliyun::Common::Struct::Base
Instance Method Details
#serialize ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/aliyun/oss/struct.rb', line 194 def serialize query_string = (query || {}).map { |k, v| [CGI.escape(k.to_s), CGI.escape(v.to_s)].join('=') }.join('&') cb = { 'callbackUrl' => "#{normalize_url(url)}?#{query_string}", 'callbackBody' => body, 'callbackBodyType' => content_type || default_content_type } cb['callbackHost'] = host if host logger.debug("Callback json: #{cb}") Base64.strict_encode64(cb.to_json) end |