@@ -33,7 +33,10 @@ image_kit = Imagekit::Client.new(
3333 password: ENV [" OPTIONAL_IMAGEKIT_IGNORES_THIS" ] # This is the default and can be omitted
3434)
3535
36- response = image_kit.files.upload(file: " https://www.example.com/public-url.jpg" , file_name: " file-name.jpg" )
36+ response = image_kit.files.upload(
37+ file: StringIO .new (" https://www.example.com/public-url.jpg" ),
38+ file_name: " file-name.jpg"
39+ )
3740
3841puts (response.videoCodec)
3942```
@@ -66,7 +69,10 @@ When the library is unable to connect to the API, or if the API returns a non-su
6669
6770``` ruby
6871begin
69- file = image_kit.files.upload(file: " https://www.example.com/public-url.jpg" , file_name: " file-name.jpg" )
72+ file = image_kit.files.upload(
73+ file: StringIO .new (" https://www.example.com/public-url.jpg" ),
74+ file_name: " file-name.jpg"
75+ )
7076rescue Imagekit ::Errors ::APIConnectionError => e
7177 puts (" The server could not be reached" )
7278 puts (e.cause) # an underlying Exception, likely raised within `net/http`
@@ -110,7 +116,7 @@ image_kit = Imagekit::Client.new(
110116
111117# Or, configure per-request:
112118image_kit.files.upload(
113- file: " https://www.example.com/public-url.jpg" ,
119+ file: StringIO . new ( " https://www.example.com/public-url.jpg" ) ,
114120 file_name: " file-name.jpg" ,
115121 request_options: {max_retries: 5 }
116122)
@@ -128,7 +134,7 @@ image_kit = Imagekit::Client.new(
128134
129135# Or, configure per-request:
130136image_kit.files.upload(
131- file: " https://www.example.com/public-url.jpg" ,
137+ file: StringIO . new ( " https://www.example.com/public-url.jpg" ) ,
132138 file_name: " file-name.jpg" ,
133139 request_options: {timeout: 5 }
134140)
@@ -163,7 +169,7 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
163169``` ruby
164170response =
165171 image_kit.files.upload(
166- file: " https://www.example.com/public-url.jpg" ,
172+ file: StringIO . new ( " https://www.example.com/public-url.jpg" ) ,
167173 file_name: " file-name.jpg" ,
168174 request_options: {
169175 extra_query: {my_query_parameter: value},
@@ -210,17 +216,26 @@ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitio
210216You can provide typesafe request parameters like so:
211217
212218``` ruby
213- image_kit.files.upload(file: " https://www.example.com/public-url.jpg" , file_name: " file-name.jpg" )
219+ image_kit.files.upload(
220+ file: StringIO .new (" https://www.example.com/public-url.jpg" ),
221+ file_name: " file-name.jpg"
222+ )
214223```
215224
216225Or, equivalently:
217226
218227``` ruby
219228# Hashes work, but are not typesafe:
220- image_kit.files.upload(file: " https://www.example.com/public-url.jpg" , file_name: " file-name.jpg" )
229+ image_kit.files.upload(
230+ file: StringIO .new (" https://www.example.com/public-url.jpg" ),
231+ file_name: " file-name.jpg"
232+ )
221233
222234# You can also splat a full Params class:
223- params = Imagekit ::FileUploadParams .new (file: " https://www.example.com/public-url.jpg" , file_name: " file-name.jpg" )
235+ params = Imagekit ::FileUploadParams .new (
236+ file: StringIO .new (" https://www.example.com/public-url.jpg" ),
237+ file_name: " file-name.jpg"
238+ )
224239image_kit.files.upload(** params)
225240```
226241
0 commit comments