Method: Stripe::FileService#create

Defined in:
lib/stripe/services/file_service.rb

#create(params = {}, opts = {}) ⇒ Object

To upload a file to Stripe, you need to send a request of type multipart/form-data. Include the file you want to upload in the request, and the parameters for creating a file.

All of Stripe’s officially supported Client libraries support sending multipart/form-data.



9
10
11
12
13
14
15
16
17
# File 'lib/stripe/services/file_service.rb', line 9

def create(params = {}, opts = {})
  if params[:file] && !params[:file].is_a?(String) && !params[:file].respond_to?(:read)
    raise ArgumentError, "file must respond to `#read`"
  end

  opts = { content_type: MultipartEncoder::MULTIPART_FORM_DATA }.merge(Util.normalize_opts(opts))

  request(method: :post, path: "/v1/files", params: params, opts: opts, base_address: :files)
end