Sha256: 280a27c0a7916437a3798371bad59d8ea3723fcd5f27a4c6e60fbf81f6f02217

Contents?: true

Size: 844 Bytes

Versions: 9

Compression:

Stored size: 844 Bytes

Contents

module Stripe
  class FileUpload < APIResource
    extend Stripe::APIOperations::Create
    extend Stripe::APIOperations::List

    def self.resource_url
      "/v1/files"
    end

    def self.request(method, url, params={}, opts={})
      opts = {
        :api_base => Stripe::uploads_base
      }.merge(Util.normalize_opts(opts))
      super
    end

    def self.create(params={}, opts={})
      # rest-client would accept a vanilla `File` for upload, but Faraday does
      # not. Support the old API by wrapping a `File` with an `UploadIO` object
      # if we're given one.
      if params[:file] && params[:file].is_a?(File)
        params[:file] = Faraday::UploadIO.new(params[:file], nil)
      end

      opts = {
        :content_type => 'multipart/form-data',
      }.merge(Util.normalize_opts(opts))
      super
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stripe-2.5.0 lib/stripe/file_upload.rb
stripe-2.4.0 lib/stripe/file_upload.rb
stripe-2.3.0 lib/stripe/file_upload.rb
stripe-2.2.1 lib/stripe/file_upload.rb
stripe-2.2.0 lib/stripe/file_upload.rb
stripe-2.1.0 lib/stripe/file_upload.rb
stripe-2.0.3 lib/stripe/file_upload.rb
stripe-2.0.2 lib/stripe/file_upload.rb
stripe-2.0.1 lib/stripe/file_upload.rb