Skip to content

Commit 4c04de9

Browse files
feat(api): manual updates
1 parent 6c0d9f3 commit 4c04de9

File tree

8 files changed

+74
-35
lines changed

8 files changed

+74
-35
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5ce78cb448cc4520f5fbcc753452e0237b50a4bf64902e0548a8ad24bbdc82cf.yml
3-
openapi_spec_hash: fd8ac4c2cdddc3d3a0b0c81be6a9edfe
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml
3+
openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a
44
config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3841
puts(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
6871
begin
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+
)
7076
rescue 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:
112118
image_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:
130136
image_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
164170
response =
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
210216
You 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

216225
Or, 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+
)
224239
image_kit.files.upload(**params)
225240
```
226241

lib/imagekit/models/file_upload_params.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ class FileUploadParams < Imagekit::Internal::Type::BaseModel
88
include Imagekit::Internal::Type::RequestParameters
99

1010
# @!attribute file
11-
# The URL of the file to upload. A publicly reachable URL that ImageKit servers
12-
# can fetch. The server must receive the response headers within 8 seconds;
13-
# otherwise the request fails with 400 Bad Request.
11+
# The API accepts any of the following:
1412
#
15-
# @return [String]
16-
required :file, String
13+
# - **Binary data** – send the raw bytes as `multipart/form-data`.
14+
# - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can
15+
# fetch.
16+
# - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
17+
#
18+
# When supplying a URL, the server must receive the response headers within 8
19+
# seconds; otherwise the request fails with 400 Bad Request.
20+
#
21+
# @return [Pathname, StringIO, IO, String, Imagekit::FilePart]
22+
required :file, Imagekit::Internal::Type::FileInput
1723

1824
# @!attribute file_name
1925
# The name with which the file has to be uploaded. The file name can contain:
@@ -234,7 +240,7 @@ class FileUploadParams < Imagekit::Internal::Type::BaseModel
234240
# Some parameter documentations has been truncated, see
235241
# {Imagekit::Models::FileUploadParams} for more details.
236242
#
237-
# @param file [String] The URL of the file to upload. A publicly reachable URL that ImageKit servers ca
243+
# @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following:
238244
#
239245
# @param file_name [String] The name with which the file has to be uploaded.
240246
#

lib/imagekit/resources/files.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def rename(params)
221221
#
222222
# @overload upload(file:, file_name:, token: nil, checks: nil, custom_coordinates: nil, custom_metadata: nil, description: nil, expire: nil, extensions: nil, folder: nil, is_private_file: nil, is_published: nil, overwrite_ai_tags: nil, overwrite_custom_metadata: nil, overwrite_file: nil, overwrite_tags: nil, public_key: nil, response_fields: nil, signature: nil, tags: nil, transformation: nil, use_unique_file_name: nil, webhook_url: nil, request_options: {})
223223
#
224-
# @param file [String] The URL of the file to upload. A publicly reachable URL that ImageKit servers ca
224+
# @param file [Pathname, StringIO, IO, String, Imagekit::FilePart] The API accepts any of the following:
225225
#
226226
# @param file_name [String] The name with which the file has to be uploaded.
227227
#

rbi/imagekit/models/file_upload_params.rbi

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ module Imagekit
1111
T.any(Imagekit::FileUploadParams, Imagekit::Internal::AnyHash)
1212
end
1313

14-
# The URL of the file to upload. A publicly reachable URL that ImageKit servers
15-
# can fetch. The server must receive the response headers within 8 seconds;
16-
# otherwise the request fails with 400 Bad Request.
17-
sig { returns(String) }
14+
# The API accepts any of the following:
15+
#
16+
# - **Binary data** – send the raw bytes as `multipart/form-data`.
17+
# - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can
18+
# fetch.
19+
# - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
20+
#
21+
# When supplying a URL, the server must receive the response headers within 8
22+
# seconds; otherwise the request fails with 400 Bad Request.
23+
sig { returns(Imagekit::Internal::FileInput) }
1824
attr_accessor :file
1925

2026
# The name with which the file has to be uploaded. The file name can contain:
@@ -284,7 +290,7 @@ module Imagekit
284290

285291
sig do
286292
params(
287-
file: String,
293+
file: Imagekit::Internal::FileInput,
288294
file_name: String,
289295
token: String,
290296
checks: String,
@@ -319,9 +325,15 @@ module Imagekit
319325
).returns(T.attached_class)
320326
end
321327
def self.new(
322-
# The URL of the file to upload. A publicly reachable URL that ImageKit servers
323-
# can fetch. The server must receive the response headers within 8 seconds;
324-
# otherwise the request fails with 400 Bad Request.
328+
# The API accepts any of the following:
329+
#
330+
# - **Binary data** – send the raw bytes as `multipart/form-data`.
331+
# - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can
332+
# fetch.
333+
# - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
334+
#
335+
# When supplying a URL, the server must receive the response headers within 8
336+
# seconds; otherwise the request fails with 400 Bad Request.
325337
file:,
326338
# The name with which the file has to be uploaded. The file name can contain:
327339
#
@@ -450,7 +462,7 @@ module Imagekit
450462
sig do
451463
override.returns(
452464
{
453-
file: String,
465+
file: Imagekit::Internal::FileInput,
454466
file_name: String,
455467
token: String,
456468
checks: String,

rbi/imagekit/resources/files.rbi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ module Imagekit
189189
# technologies.
190190
sig do
191191
params(
192-
file: String,
192+
file: Imagekit::Internal::FileInput,
193193
file_name: String,
194194
token: String,
195195
checks: String,
@@ -224,9 +224,15 @@ module Imagekit
224224
).returns(Imagekit::Models::FileUploadResponse)
225225
end
226226
def upload(
227-
# The URL of the file to upload. A publicly reachable URL that ImageKit servers
228-
# can fetch. The server must receive the response headers within 8 seconds;
229-
# otherwise the request fails with 400 Bad Request.
227+
# The API accepts any of the following:
228+
#
229+
# - **Binary data** – send the raw bytes as `multipart/form-data`.
230+
# - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can
231+
# fetch.
232+
# - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
233+
#
234+
# When supplying a URL, the server must receive the response headers within 8
235+
# seconds; otherwise the request fails with 400 Bad Request.
230236
file:,
231237
# The name with which the file has to be uploaded. The file name can contain:
232238
#

sig/imagekit/models/file_upload_params.rbs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Imagekit
22
module Models
33
type file_upload_params =
44
{
5-
file: String,
5+
file: Imagekit::Internal::file_input,
66
file_name: String,
77
token: String,
88
checks: String,
@@ -32,7 +32,7 @@ module Imagekit
3232
extend Imagekit::Internal::Type::RequestParameters::Converter
3333
include Imagekit::Internal::Type::RequestParameters
3434

35-
attr_accessor file: String
35+
attr_accessor file: Imagekit::Internal::file_input
3636

3737
attr_accessor file_name: String
3838

@@ -127,7 +127,7 @@ module Imagekit
127127
def webhook_url=: (String) -> String
128128

129129
def initialize: (
130-
file: String,
130+
file: Imagekit::Internal::file_input,
131131
file_name: String,
132132
?token: String,
133133
?checks: String,
@@ -154,7 +154,7 @@ module Imagekit
154154
) -> void
155155

156156
def to_hash: -> {
157-
file: String,
157+
file: Imagekit::Internal::file_input,
158158
file_name: String,
159159
token: String,
160160
checks: String,

sig/imagekit/resources/files.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module Imagekit
4444
) -> Imagekit::Models::FileRenameResponse
4545

4646
def upload: (
47-
file: String,
47+
file: Imagekit::Internal::file_input,
4848
file_name: String,
4949
?token: String,
5050
?checks: String,

0 commit comments

Comments
 (0)