Skip to content

Commit 0daa175

Browse files
feat(api): manual updates
1 parent 6ec4a94 commit 0daa175

File tree

6 files changed

+36
-22
lines changed

6 files changed

+36
-22
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: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ $client = new Client(
5252
password: getenv("OPTIONAL_IMAGEKIT_IGNORES_THIS") ?: "do_not_set",
5353
);
5454

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

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

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

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

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

src/Core/ServiceContracts/FilesContract.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ public function rename(
104104
/**
105105
* @api
106106
*
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.
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.
108114
* @param string $fileName The name with which the file has to be uploaded.
109115
* The file name can contain:
110116
*

src/Core/Services/FilesService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,13 @@ 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 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.
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.
261267
* @param string $fileName The name with which the file has to be uploaded.
262268
* The file name can contain:
263269
*

src/Files/FileUploadParams.php

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

6868
/**
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.
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.
7076
*/
7177
#[Api]
7278
public string $file;
@@ -338,7 +344,13 @@ public static function with(
338344
}
339345

340346
/**
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.
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.
342354
*/
343355
public function withFile(string $file): self
344356
{

tests/Services/FilesTest.php

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

166-
$result = $this->client->files->upload(
167-
file: 'https://www.example.com/path/to-image.jpg',
168-
fileName: 'fileName'
169-
);
166+
$result = $this->client->files->upload(file: 'file', fileName: 'fileName');
170167

171168
$this->assertTrue(true); // @phpstan-ignore-line
172169
}
@@ -178,10 +175,7 @@ public function testUploadWithOptionalParams(): void
178175
$this->markTestSkipped('Prism tests are disabled');
179176
}
180177

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

186180
$this->assertTrue(true); // @phpstan-ignore-line
187181
}

0 commit comments

Comments
 (0)