class Stripe::File

Constants

OBJECT_NAME
OBJECT_NAME_ALT

This resource can have two different object names. In latter API versions, only `file` is used, but since stripe-ruby may be used with any API version, we need to support deserializing the older `file_upload` object into the same class.

Public Class Methods

create(params = {}, opts = {}) click to toggle source
Calls superclass method
# File lib/stripe/resources/file.rb, line 20
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`-like object with an
  # `UploadIO` object if we're given one.
  if params[:file] && !params[:file].is_a?(String)
    unless params[:file].respond_to?(:read)
      raise ArgumentError, "file must respond to `#read`"
    end

    params[:file] = Faraday::UploadIO.new(params[:file], nil)
  end

  opts = {
    api_base: Stripe.uploads_base,
    content_type: "multipart/form-data",
  }.merge(Util.normalize_opts(opts))
  super
end
resource_url() click to toggle source
# File lib/stripe/resources/file.rb, line 16
def self.resource_url
  "/v1/files"
end