Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 832fb26

Browse files
authored
refactor: create a separate section for uploading multiple files (#335)
Signed-off-by: MDzaja <[email protected]>
1 parent 34b8ca6 commit 832fb26

File tree

3 files changed

+227
-167
lines changed

3 files changed

+227
-167
lines changed

public/llms-full.txt

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ await sandbox.fs.createFolder("/workspace/new-dir", "755")
184184

185185
Daytona SDK provides options to read, write, upload, download, and delete files in Sandboxes using Python and TypeScript.
186186

187+
#### Uploading a Single File
188+
189+
If you want to upload a single file, you can do it as follows:
190+
187191
```python
188192

189193
root_dir = sandbox.get_user_root_dir()
@@ -194,8 +198,31 @@ with open("local_file.txt", "rb") as f:
194198
content = f.read()
195199
sandbox.fs.upload_file(root_dir + "/remote_file.txt", content)
196200

197-
# Upload multiple files at once
201+
```
202+
```typescript
203+
204+
const rootDir = await workspace.getUserRootDir()
205+
206+
// Upload a single file
207+
const fileContent = new File(
208+
[Buffer.from('Hello, World!')],
209+
'data.txt',
210+
{ type: 'text/plain' }
211+
)
212+
await workspace.fs.uploadFile(rootDir + "/data.txt", fileContent)
213+
214+
```
198215

216+
217+
#### Uploading Multiple Files
218+
219+
The following example shows how to efficiently upload multiple files with a single method call.
220+
221+
```python
222+
223+
root_dir = sandbox.get_user_root_dir()
224+
225+
# Upload multiple files at once
199226
files_to_upload = []
200227

201228
with open("file1.txt", "rb") as f1:
@@ -223,14 +250,6 @@ sandbox.fs.upload_files(files_to_upload)
223250

224251
const rootDir = await workspace.getUserRootDir()
225252

226-
// Upload a single file
227-
const fileContent = new File(
228-
[Buffer.from('Hello, World!')],
229-
'data.txt',
230-
{ type: 'text/plain' }
231-
)
232-
await workspace.fs.uploadFile(rootDir + "/data.txt", fileContent)
233-
234253
// Upload multiple files at once
235254
const files = [
236255
{
@@ -251,7 +270,6 @@ await workspace.fs.uploadFiles(files)
251270

252271
```
253272

254-
255273
### Downloading Files
256274

257275
The following commands downloads the file `file1.txt` from the Sandbox user's root directory and prints out the content:

0 commit comments

Comments
 (0)