# Input Sources

Pass a path, bytes, a file-like object, a framework upload, or a URL — with the right API for each language.

All three SDKs dispatch by **file extension**, so a path carries its own
extension and byte sources need a `filename`.

## Local path

```python
# Python
from py_chunks import get_chunks
chunks = get_chunks("/data/report.pdf")
```

```ts
// JavaScript (Node / Bun only)

const chunks = await getChunks("./report.pdf");
```

```rust
// Rust
let chunks = chunks_rs::get_chunks("report.pdf", "default", 3, 1, 3, 15)?;
```

## Raw bytes

When you only have bytes, supply a `filename` so the engine can route by
extension.

```python
from py_chunks import get_chunks_from_bytes

with open("report.pdf", "rb") as f:
    data = f.read()

chunks = get_chunks_from_bytes(data, "report.pdf")   # filename drives dispatch
```

```ts
import fs from "node:fs";
import { getChunks } from "js-chunks";

const bytes = new Uint8Array(fs.readFileSync("report.pdf"));
const chunks = await getChunks(bytes, { filename: "report.pdf" });
```

```rust
use chunks_rs::get_chunks_from_bytes;

let data = std::fs::read("report.pdf")?;
// (data, filename, mode, window_size, overlap, sentences_per_chunk, paragraphs_per_page)
let chunks = get_chunks_from_bytes(&data, "report.pdf", "default", 3, 1, 3, 15)?;
```

- **Python**: `get_chunks_from_bytes(data, filename)` — or `get_chunks(data, filename=...)`.
- **JavaScript**: pass a `Uint8Array`, `ArrayBuffer`, Node `Buffer`, or a named
  `Blob`; a `Blob` supplies its own name.
- **Rust**: `get_chunks_from_bytes(&data, filename, mode, window_size, overlap, sentences_per_chunk, paragraphs_per_page)`.

## File-like objects & uploads

  `get_chunks_from_fileobj(file_obj, filename=None)` for file-like objects, and
  `get_chunks_from_upload(upload_file)` for FastAPI / Starlette / Django uploads.
  If an upload's `read()` is async, read the bytes yourself and use the bytes
  API. See [Framework Integration](/docs/framework-integration).

  Pass a `Blob` (browsers), or an `ArrayBuffer` / `Uint8Array` / `Buffer` (Node)
  with a `filename`. There are no separate helper functions — `getChunks` is
  polymorphic over the source type.

  Read the bytes yourself (`std::fs::read`, an HTTP body, etc.) and call
  `get_chunks_from_bytes(...)`. The per-format modules under `chunks_rs::formats`
  also expose `*_from_bytes` entry points.

## Remote / URL sources

- **Python**: `get_chunks_from_s3_presigned_url(url, filename=None, timeout=60)`,
  or `get_chunks("https://…")` which auto-detects `http`/`https`.
- **JavaScript / Rust**: fetch the bytes first, then pass them with a `filename`.

```ts
// JavaScript
const res = await fetch(url);
const bytes = new Uint8Array(await res.arrayBuffer());
const chunks = await getChunks(bytes, { filename: "report.pdf" });
```
