Skip to main content
The getFile() method retrieves a file from your sandbox’s filesystem and returns it as a standard Web Response object, allowing you to handle the data in multiple formats: text, JSON, binary, or Blob. All file paths must start with ~ or the absolute path /home/damner/code to ensure access is confined to the sandbox’s isolated workspace. If the requested file doesn’t exist or the path is invalid, an error is thrown.

getFile(path)

Description: Retrieves a file from the sandbox filesystem. Returns a standard Response object that you can read as text, binary, blob, etc. Parameters:
ParameterTypeRequiredDescription
pathstringYesFile path (must start with ~ or /home/damner/code)
Returns: Promise<Response> - Standard fetch Response object with methods:
  • .text() - Read as string
  • .arrayBuffer() - Read as binary
  • .blob() - Read as Blob
  • .json() - Parse as JSON
Example:
// Read text file
const response = await sandbox.getFile('~/script.js')
const content = await response.text()
console.log(content)