Skip to content

Commit de13f68

Browse files
feat(api): manual updates
1 parent c959bcf commit de13f68

File tree

6 files changed

+36
-26
lines changed

6 files changed

+36
-26
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-5ce78cb448cc4520f5fbcc753452e0237b50a4bf64902e0548a8ad24bbdc82cf.yml
3-
openapi_spec_hash: fd8ac4c2cdddc3d3a0b0c81be6a9edfe
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ public function rename(
104104
/**
105105
* @api
106106
*
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.
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.
109114
* @param string $fileName The name with which the file has to be uploaded.
110115
* The file name can contain:
111116
*

src/Core/Services/FilesService.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +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 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.
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.
262267
* @param string $fileName The name with which the file has to be uploaded.
263268
* The file name can contain:
264269
*

src/Files/FileUploadParams.php

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

7979
/**
80-
* The URL of the file to upload. A publicly reachable URL that ImageKit servers can fetch.
81-
* The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
80+
* The API accepts any of the following:
81+
*
82+
* - **Binary data** – send the raw bytes as `multipart/form-data`.
83+
* - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
84+
* - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
85+
*
86+
* When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
8287
*/
8388
#[Api]
8489
public string $file;
@@ -350,8 +355,13 @@ public static function with(
350355
}
351356

352357
/**
353-
* The URL of the file to upload. A publicly reachable URL that ImageKit servers can fetch.
354-
* The server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
358+
* The API accepts any of the following:
359+
*
360+
* - **Binary data** – send the raw bytes as `multipart/form-data`.
361+
* - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
362+
* - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
363+
*
364+
* When supplying a URL, the server must receive the response headers within 8 seconds; otherwise the request fails with 400 Bad Request.
355365
*/
356366
public function withFile(string $file): self
357367
{

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://example.com',
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://example.com',
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)