# Download

```typescript
import { f0 } from "file0";
import { Readable } from "stream";
import fs from "fs";

// Get file metadata (name, size, public url, etc..)
const metadata = await f0.get("logs.txt");

// Download a text file
const text = await f0.get("hello.txt", { as: "text" });

// Download a json object
const obj = await f0.get("data.json", { as: "json" });

// Download as a stream and save to the file system
const fileStream = await f0.get("logs.txt", { as: "stream"});
Readable
  .fromWeb(fileStream)
  .pipe(fs.createWriteStream("./logs.txt"));

// Download as a buffer
const file = await f0.get("image.png", { as: "buffer" });
// returns the web-compatible ArrayBuffer
// To convert it to a Node.js Buffer:
const nodejsBuffer = Buffer.from(file);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.file0.dev/sdk/download.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
