Skip to content

Commit 5300660

Browse files
chore(internal): codegen related update (#154)
1 parent 01425c0 commit 5300660

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ for datasource in first_page.items:
134134
# Remove `await` for non-async usage.
135135
```
136136

137+
## File uploads
138+
139+
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)`.
140+
141+
```python
142+
from pathlib import Path
143+
from asktable import Asktable
144+
145+
client = Asktable()
146+
147+
client.datasources.add_file(
148+
datasource_id="datasource_id",
149+
file=Path("/path/to/file"),
150+
)
151+
```
152+
153+
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.
154+
137155
## Handling errors
138156

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

src/asktable/_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/DataMini/asktable-python/tree/main#file-uploads"
3838
) from None
3939

4040

0 commit comments

Comments
 (0)