File System
Transfer files between your application and the sandbox using the sandbox API. All file operations use the same bearer token as the rest of the API.
Upload
Section titled “Upload”Send a file into the sandbox. Parent directories are created automatically if they do not exist.
const content = Buffer.from('print("hello")')await sandbox.uploadFile('/workspace/hello.py', content)content = b'print("hello")'sandbox.upload_file('/workspace/hello.py', content)content := []byte(`print("hello")`)err := sandbox.UploadFile(ctx, "/workspace/hello.py", content)let content = b"print(\"hello\")";sandbox.upload_file("/workspace/hello.py", content)?;byte[] content = "print(\"hello\")".getBytes();sandbox.uploadFile("/workspace/hello.py", content);Download
Section titled “Download”Retrieve a file from the sandbox. The response is the raw file bytes.
const bytes = await sandbox.downloadFile('/workspace/output.txt')console.log(bytes.toString())data = sandbox.download_file('/workspace/output.txt')print(data.decode())data, err := sandbox.DownloadFile(ctx, "/workspace/output.txt")let data = sandbox.download_file("/workspace/output.txt")?;byte[] data = sandbox.downloadFile("/workspace/output.txt");System.out.println(new String(data));Common Patterns
Section titled “Common Patterns”Upload and run a script
Section titled “Upload and run a script”await sandbox.uploadFile('/run.sh', Buffer.from('#!/bin/bash\necho hello'))const result = await sandbox.exec({ command: 'bash /run.sh' })console.log(result.stdout)sandbox.upload_file('/run.sh', b'#!/bin/bash\necho hello')result = sandbox.exec_command('bash /run.sh')print(result['stdout'])_ = sandbox.UploadFile(ctx, "/run.sh", []byte("#!/bin/bash\necho hello"))result, err := sandbox.ExecCommand(ctx, "bash /run.sh")fmt.Println(result.Stdout)sandbox.upload_file("/run.sh", b"#!/bin/bash\necho hello")?;let result = sandbox.exec(aerolvm_sdk::ExecRequest { command: "bash /run.sh".to_string(), ..Default::default()})?;println!("{}", result.stdout);sandbox.uploadFile("/run.sh", "#!/bin/bash\necho hello".getBytes());ExecResult result = sandbox.exec(new ExecOptions().setCommand("bash /run.sh"));System.out.println(result.stdout);Retrieve generated output
Section titled “Retrieve generated output”await sandbox.exec({ command: 'python3 -c "import json; json.dump({\'x\': 1}, open(\'/out.json\', \'w\'))"' })const bytes = await sandbox.downloadFile('/out.json')const data = JSON.parse(bytes.toString())sandbox.exec_command("python3 -c \"import json; json.dump({'x': 1}, open('/out.json', 'w'))\"")data = sandbox.download_file('/out.json')import jsonprint(json.loads(data))sandbox.ExecCommand(ctx, `python3 -c "import json; json.dump({'x': 1}, open('/out.json', 'w'))"`)data, _ := sandbox.DownloadFile(ctx, "/out.json")sandbox.exec(aerolvm_sdk::ExecRequest { command: r#"python3 -c "import json; json.dump({'x': 1}, open('/out.json', 'w'))""#.to_string(), ..Default::default()})?;let data = sandbox.download_file("/out.json")?;sandbox.exec(new ExecOptions().setCommand("python3 -c \"import json; json.dump({'x': 1}, open('/out.json', 'w'))\""));byte[] data = sandbox.downloadFile("/out.json");Limits
Section titled “Limits”File uploads are limited to 256 MB by default. For larger transfers, use External Storage to mount an S3 bucket or NFS share directly into the sandbox.