Skip to content

Commit f3f02a3

Browse files
chore(internal): codegen related update (#124)
1 parent a88062c commit f3f02a3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: README.md

+17
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
7777

7878
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
7979

80+
## File uploads
81+
82+
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)`.
83+
84+
```python
85+
from pathlib import Path
86+
from browserbase import Browserbase
87+
88+
client = Browserbase()
89+
90+
client.extensions.create(
91+
file=Path("/path/to/file"),
92+
)
93+
```
94+
95+
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.
96+
8097
## Handling errors
8198

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

Diff for: src/browserbase/_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/browserbase/sdk-python/tree/main#file-uploads"
3838
) from None
3939

4040

0 commit comments

Comments
 (0)