Skip to content

Commit cb1bf4f

Browse files
chore(internal): codegen related update (#551)
1 parent 6179450 commit cb1bf4f

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,25 @@ for devbox in first_page.devboxes:
136136
# Remove `await` for non-async usage.
137137
```
138138

139+
## File uploads
140+
141+
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)`.
142+
143+
```python
144+
from pathlib import Path
145+
from runloop_api_client import Runloop
146+
147+
client = Runloop()
148+
149+
client.devboxes.upload_file(
150+
id="id",
151+
path="path",
152+
file=Path("/path/to/file"),
153+
)
154+
```
155+
156+
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.
157+
139158
## Handling errors
140159

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

src/runloop_api_client/_files.py

Lines changed: 1 addition & 1 deletion
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/runloopai/api-client-python/tree/main#file-uploads"
3838
) from None
3939

4040

0 commit comments

Comments
 (0)