Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bun related docs (@stonega) #1129

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion site/docs/guide/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,20 @@ new InputFile("/path/to/file");
new InputFile(await Deno.open("/path/to/file"));
```

```ts [Bun]
// Send a local file.
new InputFile("/path/to/file");

// Send a `BunFile` instance.
new InputFile(await Bun.file("/path/to/file").bytes());
```

:::

#### Uploading Raw Binary Data

You can also send a `Buffer` object, or an iterator that yields `Buffer` objects.
On Deno, you can send `Blob` objects, too.
On Deno and Bun you can send `Blob` objects, too.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
On Deno and Bun you can send `Blob` objects, too.
On Deno and Bun, you can send `Blob` objects, too.


::: code-group

Expand Down Expand Up @@ -215,6 +223,20 @@ new InputFile(function* () {
});
```

```ts [Bun]
// Send a blob.
const blob = new Blob("ABC", { type: "text/plain" });
new InputFile(blob);
// Send a buffer or a byte array.
const buffer = Uint8Array.from([65, 66, 67]);
new InputFile(buffer); // "ABC"
// Send an iterable.
new InputFile(function* () {
// "ABCABCABCABC"
for (let i = 0; i < 4; i++) yield buffer;
});
```

:::

#### Downloading and Reuploading a File
Expand Down
Loading