Skip to content
Open
Changes from all commits
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
15 changes: 15 additions & 0 deletions docs/filesystem/upload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

## Upload single file

Read the file from your local filesystem and pass its contents to `files.write()`.

<CodeGroup>
```js JavaScript & TypeScript
import fs from 'fs'

Check warning on line 14 in docs/filesystem/upload.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/filesystem/upload.mdx#L14

Did you really mean 'fs'?
import { Sandbox } from 'e2b'

const sandbox = await Sandbox.create()
Expand All @@ -31,6 +33,19 @@
```
</CodeGroup>

The upload has a default request timeout of 60 seconds. If you're uploading large files that take longer to transfer, override it by passing `requestTimeoutMs` (JavaScript & TypeScript) or `request_timeout` (Python).

<CodeGroup>
```js JavaScript & TypeScript
// Override the default 60 second request timeout with 120 seconds
await sandbox.files.write('/path/in/sandbox', content, { requestTimeoutMs: 120_000 })
```
```python Python
# Override the default 60 second request timeout with 120 seconds
sandbox.files.write("/path/in/sandbox", file, request_timeout=120)
```
</CodeGroup>

## Upload with pre-signed URL

Sometimes, you may want to let users from unauthorized environments, like a browser, upload files to the sandbox.
Expand Down Expand Up @@ -88,7 +103,7 @@
const sandbox = await Sandbox.create()

// Read all files in the directory and store their paths and contents in an array
const readDirectoryFiles = (directoryPath) => {

Check warning on line 106 in docs/filesystem/upload.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/filesystem/upload.mdx#L106

Did you really mean 'directoryPath'?
// Read all files in the local directory
const files = fs.readdirSync(directoryPath);

Expand All @@ -109,7 +124,7 @@
};
});

return filesArray;

Check warning on line 127 in docs/filesystem/upload.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/filesystem/upload.mdx#L127

Did you really mean 'filesArray'?
};

// Usage example
Expand Down