@@ -184,6 +184,10 @@ await sandbox.fs.createFolder("/workspace/new-dir", "755")
184184
185185Daytona 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
189193root_dir = sandbox.get_user_root_dir()
@@ -194,8 +198,31 @@ with open("local_file.txt", "rb") as f:
194198 content = f.read()
195199sandbox.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
199226files_to_upload = []
200227
201228with open("file1.txt", "rb") as f1:
@@ -223,14 +250,6 @@ sandbox.fs.upload_files(files_to_upload)
223250
224251const 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
235254const files = [
236255 {
@@ -251,7 +270,6 @@ await workspace.fs.uploadFiles(files)
251270
252271```
253272
254-
255273### Downloading Files
256274
257275The following commands downloads the file `file1.txt` from the Sandbox user's root directory and prints out the content:
0 commit comments