Skip to content

Commit

Permalink
Removed v1/files override (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
prathmesh-stripe authored Aug 29, 2024
1 parent 8fc981b commit 27d87e9
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/stripe/resources/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ def self.object_name
"file"
end

# 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.
def self.create(params = {}, opts = {})
config = opts[:client]&.config || Stripe.config
upload_base = config.uploads_base
opts = { api_base: upload_base }.merge(Util.normalize_opts(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_stripe_object(method: :post, path: "/v1/files", params: params, opts: opts)
end

# Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top.
def self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/files", params: filters, opts: opts)
Expand All @@ -35,18 +52,5 @@ def self.object_name_alt
def self.resource_url
"/v1/files"
end

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

config = opts[:client]&.config || Stripe.config
opts = {
api_base: config.uploads_base,
content_type: MultipartEncoder::MULTIPART_FORM_DATA,
}.merge(Util.normalize_opts(opts))
super
end
end
end

0 comments on commit 27d87e9

Please sign in to comment.