Skip to content

Commit 9a4ab31

Browse files
feat(api): manual updates
1 parent 67adab7 commit 9a4ab31

File tree

6 files changed

+178
-635
lines changed

6 files changed

+178
-635
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-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml
3-
openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939
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: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555
option.WithPrivateAPIKey("My Private API Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_API_KEY")
5656
option.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")
5757
)
58-
response, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParamsFileUploadV1{
58+
response, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{
5959
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
6060
FileName: "file-name.jpg",
6161
})
@@ -299,7 +299,10 @@ When the API returns a non-success status code, we return an error with type
299299
To handle errors, we recommend that you use the `errors.As` pattern:
300300

301301
```go
302-
_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{})
302+
_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{
303+
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
304+
FileName: "file-name.jpg",
305+
})
303306
if err != nil {
304307
var apierr *imagekit.Error
305308
if errors.As(err, &apierr) {
@@ -326,7 +329,10 @@ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
326329
defer cancel()
327330
client.Files.Upload(
328331
ctx,
329-
imagekit.FileUploadParams{},
332+
imagekit.FileUploadParams{
333+
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
334+
FileName: "file-name.jpg",
335+
},
330336
// This sets the per-retry timeout
331337
option.WithRequestTimeout(20*time.Second),
332338
)
@@ -348,19 +354,19 @@ which can be used to wrap any `io.Reader` with the appropriate file name and con
348354
```go
349355
// A file from the file system
350356
file, err := os.Open("/path/to/file")
351-
imagekit.FileUploadParamsFileUploadV1{
357+
imagekit.FileUploadParams{
352358
File: file,
353359
FileName: "fileName",
354360
}
355361

356362
// A file from a string
357-
imagekit.FileUploadParamsFileUploadV1{
363+
imagekit.FileUploadParams{
358364
File: strings.NewReader("my file contents"),
359365
FileName: "fileName",
360366
}
361367

362368
// With a custom filename and contentType
363-
imagekit.FileUploadParamsFileUploadV1{
369+
imagekit.FileUploadParams{
364370
File: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),
365371
FileName: "fileName",
366372
}
@@ -383,7 +389,10 @@ client := imagekit.NewClient(
383389
// Override per-request:
384390
client.Files.Upload(
385391
context.TODO(),
386-
imagekit.FileUploadParams{},
392+
imagekit.FileUploadParams{
393+
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
394+
FileName: "file-name.jpg",
395+
},
387396
option.WithMaxRetries(5),
388397
)
389398
```
@@ -398,7 +407,10 @@ you need to examine response headers, status codes, or other details.
398407
var response *http.Response
399408
response, err := client.Files.Upload(
400409
context.TODO(),
401-
imagekit.FileUploadParams{},
410+
imagekit.FileUploadParams{
411+
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
412+
FileName: "file-name.jpg",
413+
},
402414
option.WithResponseInto(&response),
403415
)
404416
if err != nil {

client_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestUserAgentHeader(t *testing.T) {
4141
},
4242
}),
4343
)
44-
client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
44+
client.Files.Upload(context.Background(), imagekit.FileUploadParams{
4545
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
4646
FileName: "file-name.jpg",
4747
})
@@ -69,7 +69,7 @@ func TestRetryAfter(t *testing.T) {
6969
},
7070
}),
7171
)
72-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
72+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
7373
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
7474
FileName: "file-name.jpg",
7575
})
@@ -108,7 +108,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
108108
}),
109109
option.WithHeaderDel("X-Stainless-Retry-Count"),
110110
)
111-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
111+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
112112
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
113113
FileName: "file-name.jpg",
114114
})
@@ -142,7 +142,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
142142
}),
143143
option.WithHeader("X-Stainless-Retry-Count", "42"),
144144
)
145-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
145+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
146146
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
147147
FileName: "file-name.jpg",
148148
})
@@ -175,7 +175,7 @@ func TestRetryAfterMs(t *testing.T) {
175175
},
176176
}),
177177
)
178-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
178+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
179179
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
180180
FileName: "file-name.jpg",
181181
})
@@ -202,7 +202,7 @@ func TestContextCancel(t *testing.T) {
202202
)
203203
cancelCtx, cancel := context.WithCancel(context.Background())
204204
cancel()
205-
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParamsFileUploadV1{
205+
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParams{
206206
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
207207
FileName: "file-name.jpg",
208208
})
@@ -226,7 +226,7 @@ func TestContextCancelDelay(t *testing.T) {
226226
)
227227
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
228228
defer cancel()
229-
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParamsFileUploadV1{
229+
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParams{
230230
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
231231
FileName: "file-name.jpg",
232232
})
@@ -256,7 +256,7 @@ func TestContextDeadline(t *testing.T) {
256256
},
257257
}),
258258
)
259-
_, err := client.Files.Upload(deadlineCtx, imagekit.FileUploadParamsFileUploadV1{
259+
_, err := client.Files.Upload(deadlineCtx, imagekit.FileUploadParams{
260260
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
261261
FileName: "file-name.jpg",
262262
})

0 commit comments

Comments
 (0)