Class: Stripe::File
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::File
- Extended by:
- APIOperations::Create, APIOperations::List
- Defined in:
- lib/stripe/resources/file.rb
Overview
This object represents files hosted on Stripe’s servers. You can upload files with the [create file](stripe.com/docs/api#create_file) request (for example, when uploading dispute evidence). Stripe also creates files independently (for example, the results of a [Sigma scheduled query](stripe.com/docs/api#scheduled_queries)).
Related guide: [File upload guide](stripe.com/docs/file-upload)
Defined Under Namespace
Classes: CreateParams, ListParams, RetrieveParams
Constant Summary collapse
- OBJECT_NAME =
"file"- 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.
"file_upload"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Time at which the object was created.
-
#expires_at ⇒ Object
readonly
The file expires and isn’t available at this time in epoch seconds.
-
#filename ⇒ Object
readonly
The suitable name for saving the file to a filesystem.
-
#id ⇒ Object
readonly
Unique identifier for the object.
-
#links ⇒ Object
readonly
A list of [file links](stripe.com/docs/api#file_links) that point at this file.
-
#object ⇒ Object
readonly
String representing the object’s type.
-
#purpose ⇒ Object
readonly
The [purpose](stripe.com/docs/file-upload#uploading-a-file) of the uploaded file.
-
#size ⇒ Object
readonly
The size of the file object in bytes.
-
#title ⇒ Object
readonly
A suitable title for the document.
-
#type ⇒ Object
readonly
The returned file type (for example, ‘csv`, `pdf`, `jpg`, or `png`).
-
#url ⇒ Object
readonly
Use your live secret API key to download the file from this URL.
Attributes inherited from APIResource
Attributes inherited from StripeObject
Class Method Summary collapse
-
.create(params = {}, opts = {}) ⇒ Object
To upload a file to Stripe, you need to send a request of type multipart/form-data.
-
.list(params = {}, opts = {}) ⇒ Object
Returns a list of the files that your account has access to.
- .object_name ⇒ Object
- .object_name_alt ⇒ Object
- .resource_url ⇒ Object
Methods included from APIOperations::Create
Methods included from APIOperations::List
Methods inherited from APIResource
class_name, custom_method, #refresh, #request_stripe_object, #resource_url, retrieve, save_nested_resource
Methods included from APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Instance Attribute Details
#created ⇒ Object (readonly)
Time at which the object was created. Measured in seconds since the Unix epoch.
123 124 125 |
# File 'lib/stripe/resources/file.rb', line 123 def created @created end |
#expires_at ⇒ Object (readonly)
The file expires and isn’t available at this time in epoch seconds.
126 127 128 |
# File 'lib/stripe/resources/file.rb', line 126 def expires_at @expires_at end |
#filename ⇒ Object (readonly)
The suitable name for saving the file to a filesystem.
129 130 131 |
# File 'lib/stripe/resources/file.rb', line 129 def filename @filename end |
#id ⇒ Object (readonly)
Unique identifier for the object.
132 133 134 |
# File 'lib/stripe/resources/file.rb', line 132 def id @id end |
#links ⇒ Object (readonly)
A list of [file links](stripe.com/docs/api#file_links) that point at this file.
135 136 137 |
# File 'lib/stripe/resources/file.rb', line 135 def links @links end |
#object ⇒ Object (readonly)
String representing the object’s type. Objects of the same type share the same value.
138 139 140 |
# File 'lib/stripe/resources/file.rb', line 138 def object @object end |
#purpose ⇒ Object (readonly)
The [purpose](stripe.com/docs/file-upload#uploading-a-file) of the uploaded file.
141 142 143 |
# File 'lib/stripe/resources/file.rb', line 141 def purpose @purpose end |
#size ⇒ Object (readonly)
The size of the file object in bytes.
144 145 146 |
# File 'lib/stripe/resources/file.rb', line 144 def size @size end |
#title ⇒ Object (readonly)
A suitable title for the document.
147 148 149 |
# File 'lib/stripe/resources/file.rb', line 147 def title @title end |
#type ⇒ Object (readonly)
The returned file type (for example, ‘csv`, `pdf`, `jpg`, or `png`).
150 151 152 |
# File 'lib/stripe/resources/file.rb', line 150 def type @type end |
#url ⇒ Object (readonly)
Use your live secret API key to download the file from this URL.
153 154 155 |
# File 'lib/stripe/resources/file.rb', line 153 def url @url end |
Class Method Details
.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.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/stripe/resources/file.rb', line 158 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 opts = { content_type: MultipartEncoder::MULTIPART_FORM_DATA }.merge(Util.normalize_opts(opts)) request_stripe_object( method: :post, path: "/v1/files", params: params, opts: opts, base_address: :files ) end |
.list(params = {}, opts = {}) ⇒ Object
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.
175 176 177 |
# File 'lib/stripe/resources/file.rb', line 175 def self.list(params = {}, opts = {}) request_stripe_object(method: :get, path: "/v1/files", params: params, opts: opts) end |
.object_name ⇒ Object
17 18 19 |
# File 'lib/stripe/resources/file.rb', line 17 def self.object_name "file" end |
.object_name_alt ⇒ Object
184 185 186 |
# File 'lib/stripe/resources/file.rb', line 184 def self.object_name_alt "file_upload" end |
.resource_url ⇒ Object
188 189 190 |
# File 'lib/stripe/resources/file.rb', line 188 def self.resource_url "/v1/files" end |