@@ -10,22 +10,22 @@ An alternative way to get your data to the sandbox is to create a [custom sandbo
1010``` ts {{ language: 'js' }}
1111import { Sandbox } from ' @e2b/code-interpreter'
1212
13- // Read local file
14- const content = fs .readFileSync (' / local/file' )
13+ // Read local file relative to the current working directory
14+ const content = fs .readFileSync (' local/file' )
1515
1616const sbx = await Sandbox .create ()
17- // Upload file to the sandbox to path '/home/user/my-file'
17+ // Upload file to the sandbox to absolute path '/home/user/my-file'
1818await sbx .files .write (' /home/user/my-file' , content )
1919```
2020
2121``` python {{ language: 'python' }}
2222from e2b_code_interpreter import Sandbox
2323
24- sbx = Sandbox.create ()
24+ sbx = Sandbox()
2525
26- # Read local file
27- with open (" / local/file" , " rb" ) as file :
28- # Upload file to the sandbox to path '/home/user/my-file'
26+ # Read local file relative to the current working directory
27+ with open (" local/file" , " rb" ) as file :
28+ # Upload file to the sandbox to absolute path '/home/user/my-file'
2929 sbx.files.write(" /home/user/my-file" , file )
3030```
3131</CodeGroup >
@@ -39,26 +39,30 @@ We're working on a better solution.
3939``` ts {{ language: 'js' }}
4040import { Sandbox } from ' @e2b/code-interpreter'
4141
42- // Read local files
43- const fileA = fs .readFileSync (' / local/file/a' )
44- const fileB = fs .readFileSync (' / local/file/b' )
42+ // Read local file relative to the current working directory
43+ const fileA = fs .readFileSync (' local/file/a' )
44+ const fileB = fs .readFileSync (' local/file/b' )
4545
4646const sbx = await Sandbox .create ()
47- // Upload file A to the sandbox to path '/home/user/my-file-a'
48- await sbx .files .write (' /home/user/my-file-a' , content )
49- // Upload file B to the sandbox to path '/home/user/my-file-b'
50- await sbx .files .write (' /home/user/my-file-b' , content )
47+ // Upload file A to the sandbox to absolute path '/home/user/my-file-a'
48+ await sbx .files .write (' /home/user/my-file-a' , fileA )
49+ // Upload file B to the sandbox to absolute path '/home/user/my-file-b'
50+ await sbx .files .write (' /home/user/my-file-b' , fileB )
5151```
5252
5353``` python {{ language: 'python' }}
5454from e2b_code_interpreter import Sandbox
5555
56- sbx = Sandbox.create ()
56+ sbx = Sandbox()
5757
58- # Read local file
59- with open (" /local/file" , " rb" ) as file :
60- # Upload file to the sandbox to path '/home/user/my-file'
61- sbx.files.write(" /home/user/my-file" , file )
58+ # Read local file relative to the current working directory
59+ with open (" local/file/a" , " rb" ) as file :
60+ # Upload file to the sandbox to absolute path '/home/user/my-file-a'
61+ sbx.files.write(" /home/user/my-file-a" , file )
62+
63+ with open (" local/file/b" , " rb" ) as file :
64+ # Upload file to the sandbox to absolute path '/home/user/my-file-b'
65+ sbx.files.write(" /home/user/my-file-b" , file )
6266```
6367</CodeGroup >
6468
@@ -79,20 +83,20 @@ To download a file, you need to first get the file's content and then write it t
7983import { Sandbox } from ' @e2b/code-interpreter'
8084
8185const sbx = await Sandbox .create ()
82- // Download file from the sandbox to path '/home/user/my-file'
86+ // Download file from the sandbox to absolute path '/home/user/my-file'
8387const content = await sbx .files .read (' /home/user/my-file' )
84- // Write file to local path
85- fs .writeFileSync (' / local/file' , content )
88+ // Write file to local path relative to the current working directory
89+ fs .writeFileSync (' local/file' , content )
8690```
8791
8892``` python {{ language: 'python' }}
8993from e2b_code_interpreter import Sandbox
9094
91- sbx = Sandbox.create ()
92- # Download file from the sandbox to path '/home/user/my-file'
95+ sbx = Sandbox()
96+ # Download file from the sandbox to absolute path '/home/user/my-file'
9397content = sbx.files.read(' /home/user/my-file' )
94- # Write file to local path
95- with open (' / local/file' , ' w' ) as file :
98+ # Write file to local path relative to the current working directory
99+ with open (' local/file' , ' w' ) as file :
96100 file .write(content)
97101```
98102</CodeGroup >
@@ -108,31 +112,31 @@ We're working on a better solution.
108112import { Sandbox } from ' @e2b/code-interpreter'
109113
110114const sbx = await Sandbox .create ()
111- // Download file A from the sandbox to path '/home/user/my-file'
115+ // Download file A from the sandbox by absolute path '/home/user/my-file-a '
112116const contentA = await sbx .files .read (' /home/user/my-file-a' )
113- // Write file A to local path
114- fs .writeFileSync (' / local/file/a' , contentA )
117+ // Write file A to local path relative to the current working directory
118+ fs .writeFileSync (' local/file/a' , contentA )
115119
116- // Download file B from the sandbox to path '/home/user/my-file'
120+ // Download file B from the sandbox by absolute path '/home/user/my-file-b '
117121const contentB = await sbx .files .read (' /home/user/my-file-b' )
118- // Write file B to local path
119- fs .writeFileSync (' / local/file/b' , contentB )
122+ // Write file B to local path relative to the current working directory
123+ fs .writeFileSync (' local/file/b' , contentB )
120124```
121125
122126``` python {{ language: 'python' }}
123127from e2b_code_interpreter import Sandbox
124128
125- sbx = Sandbox.create ()
126- # Download file A from the sandbox to path '/home/user/my-file-a'
129+ sbx = Sandbox()
130+ # Download file A from the sandbox by absolute path '/home/user/my-file-a'
127131contentA = sbx.files.read(' /home/user/my-file-a' )
128- # Write file A to local path
129- with open (' / local/file/a' , ' w' ) as file :
132+ # Write file A to local path relative to the current working directory
133+ with open (' local/file/a' , ' w' ) as file :
130134 file .write(contentA)
131135
132- # Download file B from the sandbox to path '/home/user/my-file-b'
136+ # Download file B from the sandbox by absolute path '/home/user/my-file-b'
133137contentB = sbx.files.read(' /home/user/my-file-b' )
134- # Write file B to local path
135- with open (' / local/file/b' , ' w' ) as file :
138+ # Write file B to local path relative to the current working directory
139+ with open (' local/file/b' , ' w' ) as file :
136140 file .write(contentB)
137141```
138142</CodeGroup >
0 commit comments