Sandboxes
Files
A sandbox exposes its filesystem through four methods: readFile, writeFile, mkdir, and upload.
Every path is absolute, inside the sandbox.
Write and read a file
writeFile creates a missing file, and truncates an existing one.
readFile returns the file as a Uint8Array.
Code
A string is UTF-8.
Pass a Uint8Array for binary content.
Append to a file
Code
Upload a file into a directory
upload takes the directory, the file name, and the content, and it creates the missing parent directories:
Code
Create a directory
mkdir creates the missing parent directories too.
Pass parents: false to create only the last one.
Code
Reference
Every method also accepts signal and headers, as the client does.
See Sandbox in the source for the complete list.
Last modified on