Classes
Filesystem
sbx.files: the sandbox filesystem. Relative paths resolve against /work.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Filesystem(
sbx):Filesystem
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Filesystem
Methods
Section titled “Methods”download()
Section titled “download()”download(
remotePath,localPath):Promise<void>
Copy a file from the sandbox, creating local parent directories.
Parameters
Section titled “Parameters”remotePath
Section titled “remotePath”string
localPath
Section titled “localPath”string
Returns
Section titled “Returns”Promise<void>
downloadDir()
Section titled “downloadDir()”downloadDir(
remoteDir,localDir):Promise<void>
Copy a directory tree from the sandbox into localDir. Nothing is written outside it: absolute names and “..” are refused, an entry is never written through a symbolic link, and a link that leads outside localDir (directly or through other links) is removed and reported as an error.
Parameters
Section titled “Parameters”remoteDir
Section titled “remoteDir”string
localDir
Section titled “localDir”string
Returns
Section titled “Returns”Promise<void>
exists()
Section titled “exists()”exists(
path):Promise<boolean>
Whether a path exists (a dangling symlink counts).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<boolean>
getInfo()
Section titled “getInfo()”getInfo(
path):Promise<EntryInfo>
Describe a path without following a final symlink.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<EntryInfo>
list()
Section titled “list()”list(
path?):Promise<EntryInfo[]>
Entries of a directory (one level), sorted by name.
Parameters
Section titled “Parameters”string = "."
Returns
Section titled “Returns”Promise<EntryInfo[]>
makeDir()
Section titled “makeDir()”makeDir(
path):Promise<boolean>
Create a directory and its parents. Resolves false if it already existed.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<boolean>
read()
Section titled “read()”Call Signature
Section titled “Call Signature”read(
path,opts?):Promise<string>
A file’s contents as text (default), bytes or a Blob. Rejects with FileNotFoundError if missing.
Parameters
Section titled “Parameters”string
format?
Section titled “format?”"text"
Returns
Section titled “Returns”Promise<string>
Call Signature
Section titled “Call Signature”read(
path,opts):Promise<Uint8Array<ArrayBufferLike>>
A file’s contents as text (default), bytes or a Blob. Rejects with FileNotFoundError if missing.
Parameters
Section titled “Parameters”string
format
Section titled “format”"bytes"
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
Call Signature
Section titled “Call Signature”read(
path,opts):Promise<Blob>
A file’s contents as text (default), bytes or a Blob. Rejects with FileNotFoundError if missing.
Parameters
Section titled “Parameters”string
format
Section titled “format”"blob"
Returns
Section titled “Returns”Promise<Blob>
remove()
Section titled “remove()”remove(
path):Promise<void>
Delete a file or directory tree. Rejects with FileNotFoundError if missing.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
rename()
Section titled “rename()”rename(
oldPath,newPath):Promise<EntryInfo>
Move a file or directory (creating the destination’s parents); describes the result.
Parameters
Section titled “Parameters”oldPath
Section titled “oldPath”string
newPath
Section titled “newPath”string
Returns
Section titled “Returns”Promise<EntryInfo>
upload()
Section titled “upload()”upload(
localPath,remotePath):Promise<WriteInfo>
Copy a local file into the sandbox (keeping its permission bits).
Parameters
Section titled “Parameters”localPath
Section titled “localPath”string
remotePath
Section titled “remotePath”string
Returns
Section titled “Returns”Promise<WriteInfo>
uploadDir()
Section titled “uploadDir()”uploadDir(
localDir,remoteDir):Promise<void>
Copy a local directory tree into remoteDir (created if missing) as one tar. Symlinks are copied as links; files are owned by root.
Parameters
Section titled “Parameters”localDir
Section titled “localDir”string
remoteDir
Section titled “remoteDir”string
Returns
Section titled “Returns”Promise<void>
write()
Section titled “write()”Call Signature
Section titled “Call Signature”write(
path,data):Promise<WriteInfo>
Create or replace a file atomically (mode 0644), creating parent directories; any size works (over 15 MiB is staged in pieces). With an array, writes several files in one upload.
Parameters
Section titled “Parameters”string
string | ArrayBuffer | Uint8Array<ArrayBufferLike> | Blob
Returns
Section titled “Returns”Promise<WriteInfo>
Call Signature
Section titled “Call Signature”write(
files):Promise<WriteInfo[]>
Create or replace a file atomically (mode 0644), creating parent directories; any size works (over 15 MiB is staged in pieces). With an array, writes several files in one upload.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<WriteInfo[]>
writeFiles()
Section titled “writeFiles()”writeFiles(
files):Promise<WriteInfo[]>
Write several files in one upload, creating parent directories.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Promise<WriteInfo[]>
