Sha256: fc9032f32cd122e66bee856b6201b33dd225c3964d6498f334ced3f2c1b501ed

Contents?: true

Size: 916 Bytes

Versions: 6

Compression:

Stored size: 916 Bytes

Contents

module Refile
  # 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.
  class Signature
    # @return [String] the name of the field that the file will be uploaded as.
    attr_reader :as

    # @return [String] the id the file will receive once uploaded.
    attr_reader :id

    # @return [String] the url the file should be uploaded to.
    attr_reader :url

    # @return [String] additional fields to be sent alongside the file.
    attr_reader :fields

    # @api private
    def initialize(as:, id:, url:, fields:)
      @as = as
      @id = id
      @url = url
      @fields = fields
    end

    # @return [Hash{Symbol => Object}] an object suitable for serialization to JSON
    def as_json(*)
      { as: @as, id: @id, url: @url, fields: @fields }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refile-0.5.5 lib/refile/signature.rb
refile-0.5.4 lib/refile/signature.rb
refile-0.5.3 lib/refile/signature.rb
refile-0.5.2 lib/refile/signature.rb
refile-0.5.1 lib/refile/signature.rb
refile-0.5.0 lib/refile/signature.rb