Skip to content

Commit ca62b83

Browse files
committed
fix(docs): update README examples to use File.read instead of StringIO for file uploads
1 parent 17a776a commit ca62b83

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ When the library is unable to connect to the API, or if the API returns a non-su
529529
```ruby
530530
begin
531531
file = image_kit.files.upload(
532-
file: StringIO.new("https://www.example.com/public-url.jpg"),
532+
file: File.read("/path/to/file.jpg"),
533533
file_name: "file-name.jpg"
534534
)
535535
rescue Imagekit::Errors::APIConnectionError => e
@@ -575,7 +575,7 @@ image_kit = Imagekit::Client.new(
575575

576576
# Or, configure per-request:
577577
image_kit.files.upload(
578-
file: StringIO.new("https://www.example.com/public-url.jpg"),
578+
file: File.read("/path/to/file.jpg"),
579579
file_name: "file-name.jpg",
580580
request_options: {max_retries: 5}
581581
)
@@ -593,7 +593,7 @@ image_kit = Imagekit::Client.new(
593593

594594
# Or, configure per-request:
595595
image_kit.files.upload(
596-
file: StringIO.new("https://www.example.com/public-url.jpg"),
596+
file: File.read("/path/to/file.jpg"),
597597
file_name: "file-name.jpg",
598598
request_options: {timeout: 5}
599599
)
@@ -628,7 +628,7 @@ Note: the `extra_` parameters of the same name overrides the documented paramete
628628
```ruby
629629
response =
630630
image_kit.files.upload(
631-
file: StringIO.new("https://www.example.com/public-url.jpg"),
631+
file: File.read("/path/to/file.jpg"),
632632
file_name: "file-name.jpg",
633633
request_options: {
634634
extra_query: {my_query_parameter: value},
@@ -676,7 +676,7 @@ You can provide typesafe request parameters like so:
676676

677677
```ruby
678678
image_kit.files.upload(
679-
file: StringIO.new("https://www.example.com/public-url.jpg"),
679+
file: File.read("/path/to/file.jpg"),
680680
file_name: "file-name.jpg"
681681
)
682682
```
@@ -686,13 +686,13 @@ Or, equivalently:
686686
```ruby
687687
# Hashes work, but are not typesafe:
688688
image_kit.files.upload(
689-
file: StringIO.new("https://www.example.com/public-url.jpg"),
689+
file: File.read("/path/to/file.jpg"),
690690
file_name: "file-name.jpg"
691691
)
692692

693693
# You can also splat a full Params class:
694694
params = Imagekit::FileUploadParams.new(
695-
file: StringIO.new("https://www.example.com/public-url.jpg"),
695+
file: File.read("/path/to/file.jpg"),
696696
file_name: "file-name.jpg"
697697
)
698698
image_kit.files.upload(**params)

0 commit comments

Comments
 (0)