Skip to content

Commit 1616873

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): update via SDK Studio (#151)
1 parent 452f567 commit 1616873

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ for account in first_page.result:
142142
# Remove `await` for non-async usage.
143143
```
144144

145+
## File Uploads
146+
147+
Request parameters that correspond to file uploads can be passed as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
148+
149+
```python
150+
from pathlib import Path
151+
from cloudflare import Cloudflare
152+
153+
client = Cloudflare()
154+
155+
client.images.v1.create(
156+
account_id="023e105f4ecef8ad9ca31a8372d0c353",
157+
)
158+
```
159+
160+
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
161+
145162
## Handling errors
146163

147164
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `cloudflare.APIConnectionError` is raised.

src/cloudflare/_files.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
3434
if not is_file_content(obj):
3535
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
3636
raise RuntimeError(
37-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
37+
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/cloudflare/cloudflare-python/tree/main#file-uploads"
3838
) from None
3939

4040

0 commit comments

Comments
 (0)