Class: Refile::Signature
- Inherits:
-
Object
- Object
- Refile::Signature
- Defined in:
- lib/refile/signature.rb
Overview
A signature summarizes an HTTP request a client can make to upload a file to directly upload a file to a backend. This signature is usually generated by a backend’s ‘presign` method.
Instance Attribute Summary collapse
-
#as ⇒ String
readonly
The name of the field that the file will be uploaded as.
-
#fields ⇒ String
readonly
Additional fields to be sent alongside the file.
-
#id ⇒ String
readonly
The id the file will receive once uploaded.
-
#url ⇒ String
readonly
The url the file should be uploaded to.
Instance Method Summary collapse
-
#as_json ⇒ Hash{Symbol => Object}
An object suitable for serialization to JSON.
-
#initialize(as:, id:, url:, fields:) ⇒ Signature
constructor
private
A new instance of Signature.
-
#to_json ⇒ String
The signature serialized as JSON.
Constructor Details
#initialize(as:, id:, url:, fields:) ⇒ Signature
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Signature.
19 20 21 22 23 24 |
# File 'lib/refile/signature.rb', line 19 def initialize(as:, id:, url:, fields:) @as = as @id = id @url = url @fields = fields end |
Instance Attribute Details
#as ⇒ String (readonly)
Returns the name of the field that the file will be uploaded as.
7 8 9 |
# File 'lib/refile/signature.rb', line 7 def as @as end |
#fields ⇒ String (readonly)
Returns additional fields to be sent alongside the file.
16 17 18 |
# File 'lib/refile/signature.rb', line 16 def fields @fields end |
#id ⇒ String (readonly)
Returns the id the file will receive once uploaded.
10 11 12 |
# File 'lib/refile/signature.rb', line 10 def id @id end |
#url ⇒ String (readonly)
Returns the url the file should be uploaded to.
13 14 15 |
# File 'lib/refile/signature.rb', line 13 def url @url end |
Instance Method Details
#as_json ⇒ Hash{Symbol => Object}
Returns an object suitable for serialization to JSON.
27 28 29 |
# File 'lib/refile/signature.rb', line 27 def as_json(*) { as: @as, id: @id, url: @url, fields: @fields } end |
#to_json ⇒ String
Returns the signature serialized as JSON.
32 33 34 |
# File 'lib/refile/signature.rb', line 32 def to_json(*) as_json.to_json end |