Skip to content

Commit 79f9906

Browse files
feat(api): manual updates
1 parent aba7242 commit 79f9906

File tree

6 files changed

+26
-36
lines changed

6 files changed

+26
-36
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-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml
3-
openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9ae7b43dcfd6208ca37c32c887630ae186ec338bcdd36902b6fe5d1cc66459dc.yml
3+
openapi_spec_hash: 25fb64c067e64bcff6eaaabda26de397
44
config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ $client = new Client(
5252
password: getenv("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?: "do_not_set",
5353
);
5454

55-
$response = $client->files->upload(file: 'file', fileName: "file-name.jpg");
55+
$response = $client->files->upload(
56+
file: "https://www.example.com/public-url.jpg", fileName: "file-name.jpg"
57+
);
5658

5759
var_dump($response->videoCodec);
5860
```
@@ -74,7 +76,9 @@ When the library is unable to connect to the API, or if the API returns a non-su
7476
use ImageKit\Core\Exceptions\APIConnectionException;
7577

7678
try {
77-
$response = $client->files->upload(file: 'file', fileName: "file-name.jpg");
79+
$response = $client->files->upload(
80+
file: "https://www.example.com/public-url.jpg", fileName: "file-name.jpg"
81+
);
7882
} catch (APIConnectionException $e) {
7983
echo "The server could not be reached", PHP_EOL;
8084
var_dump($e->getPrevious());
@@ -122,7 +126,7 @@ $client = new Client(maxRetries: 0);
122126
// Or, configure per-request:
123127

124128
$result = $client->files->upload(
125-
file: 'file',
129+
file: "https://www.example.com/public-url.jpg",
126130
fileName: "file-name.jpg",
127131
requestOptions: RequestOptions::with(maxRetries: 5),
128132
);
@@ -144,7 +148,7 @@ Note: the `extra*` parameters of the same name overrides the documented paramete
144148
use ImageKit\RequestOptions;
145149

146150
$response = $client->files->upload(
147-
file: 'file',
151+
file: "https://www.example.com/public-url.jpg",
148152
fileName: "file-name.jpg",
149153
requestOptions: RequestOptions::with(
150154
extraQueryParams: ["my_query_parameter" => "value"],

src/Core/ServiceContracts/FilesContract.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,8 @@ public function rename(
104104
/**
105105
* @api
106106
*
107-
* @param string $file The API accepts any of the following:
108-
*
109-
* - **Binary data** – send the raw bytes as `multipart/form-data`.
110-
* - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
111-
* - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
112-
*
113-
* When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
107+
* @param string $file The URL of the file to upload. A publicly reachable URL that ImageKit servers can fetch.
108+
* The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
114109
* @param string $fileName The name with which the file has to be uploaded.
115110
* The file name can contain:
116111
*

src/Core/Services/FilesService.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,8 @@ public function rename(
257257
* - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more.
258258
* - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies.
259259
*
260-
* @param string $file The API accepts any of the following:
261-
*
262-
* - **Binary data** – send the raw bytes as `multipart/form-data`.
263-
* - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
264-
* - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
265-
*
266-
* When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
260+
* @param string $file The URL of the file to upload. A publicly reachable URL that ImageKit servers can fetch.
261+
* The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
267262
* @param string $fileName The name with which the file has to be uploaded.
268263
* The file name can contain:
269264
*

src/Files/FileUploadParams.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,8 @@ final class FileUploadParams implements BaseModel
6666
use SdkParams;
6767

6868
/**
69-
* The API accepts any of the following:
70-
*
71-
* - **Binary data** – send the raw bytes as `multipart/form-data`.
72-
* - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
73-
* - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
74-
*
75-
* When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
69+
* The URL of the file to upload. A publicly reachable URL that ImageKit servers can fetch.
70+
* The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
7671
*/
7772
#[Api]
7873
public string $file;
@@ -344,13 +339,8 @@ public static function with(
344339
}
345340

346341
/**
347-
* The API accepts any of the following:
348-
*
349-
* - **Binary data** – send the raw bytes as `multipart/form-data`.
350-
* - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
351-
* - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
352-
*
353-
* When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
342+
* The URL of the file to upload. A publicly reachable URL that ImageKit servers can fetch.
343+
* The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
354344
*/
355345
public function withFile(string $file): self
356346
{

tests/Services/FilesTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ public function testUpload(): void
163163
$this->markTestSkipped('Prism tests are disabled');
164164
}
165165

166-
$result = $this->client->files->upload(file: 'file', fileName: 'fileName');
166+
$result = $this->client->files->upload(
167+
file: 'https://example.com',
168+
fileName: 'fileName'
169+
);
167170

168171
$this->assertTrue(true); // @phpstan-ignore-line
169172
}
@@ -175,7 +178,10 @@ public function testUploadWithOptionalParams(): void
175178
$this->markTestSkipped('Prism tests are disabled');
176179
}
177180

178-
$result = $this->client->files->upload(file: 'file', fileName: 'fileName');
181+
$result = $this->client->files->upload(
182+
file: 'https://example.com',
183+
fileName: 'fileName'
184+
);
179185

180186
$this->assertTrue(true); // @phpstan-ignore-line
181187
}

0 commit comments

Comments
 (0)