Skip to content

Commit 6ec4a94

Browse files
feat(api): manual updates
1 parent 5bce0a4 commit 6ec4a94

File tree

6 files changed

+22
-36
lines changed

6 files changed

+22
-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-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml
3+
openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939
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: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,7 @@ 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 A publicly reachable URL that ImageKit’s servers can fetch. The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
114108
* @param string $fileName The name with which the file has to be uploaded.
115109
* The file name can contain:
116110
*

src/Core/Services/FilesService.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,7 @@ 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 A publicly reachable URL that ImageKit’s servers can fetch. The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
267261
* @param string $fileName The name with which the file has to be uploaded.
268262
* The file name can contain:
269263
*

src/Files/FileUploadParams.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ 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+
* A publicly reachable URL that ImageKit’s servers can fetch. The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
7670
*/
7771
#[Api]
7872
public string $file;
@@ -344,13 +338,7 @@ public static function with(
344338
}
345339

346340
/**
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.
341+
* A publicly reachable URL that ImageKit’s servers can fetch. The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
354342
*/
355343
public function withFile(string $file): self
356344
{

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://www.example.com/path/to-image.jpg',
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://www.example.com/path/to-image.jpg',
183+
fileName: 'fileName'
184+
);
179185

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

0 commit comments

Comments
 (0)