Skip to content
File System

File System

The File System API is provided by envd's filesystem.Filesystem Connect RPC service and the /files HTTP API. It is used to read and write files, list directories, move and delete files, and watch directory changes.

Before calling this API, see the Sandbox Runtime API to get the envd endpoint and envdAccessToken.

Connect RPC APIs use Authorization: Basic <base64("user:")> to specify the file operation user inside the sandbox. If no user is specified, envd uses the sandbox default user. Request and response bodies use protobuf JSON field names, which are lowerCamelCase.

Connect RPC Paths

MethodRequest PathTypeDescription
Stat/filesystem.Filesystem/StatUnaryGet file or directory information
ListDir/filesystem.Filesystem/ListDirUnaryList directory contents
MakeDir/filesystem.Filesystem/MakeDirUnaryCreate a directory
Move/filesystem.Filesystem/MoveUnaryMove or rename a file or directory
Remove/filesystem.Filesystem/RemoveUnaryDelete a file or directory
WatchDir/filesystem.Filesystem/WatchDirServer streamingWatch directory changes
CreateWatcher/filesystem.Filesystem/CreateWatcherUnaryCreate a non-streaming directory watcher
GetWatcherEvents/filesystem.Filesystem/GetWatcherEventsUnaryFetch watcher events
RemoveWatcher/filesystem.Filesystem/RemoveWatcherUnaryDelete a watcher

EntryInfo Fields

FieldTypeDescription
namestringFile name
typestringFile type. Available values: FILE_TYPE_FILE, FILE_TYPE_DIRECTORY
pathstringFull path
sizeintegerFile size in bytes
modeintegerFile mode
permissionsstringPermission string
ownerstringOwner
groupstringGroup
modifiedTimestringLast modified time
symlinkTargetstringSymbolic link target path

Get File Information

Request Path

http
POST /filesystem.Filesystem/Stat

Request Parameters

ParameterTypeRequiredDescription
pathstringYesFile or directory path

Request Example

bash
curl -X POST "$ENVD_API_BASE/filesystem.Filesystem/Stat" \
  -H "X-Access-Token: $ENVD_ACCESS_TOKEN" \
  -H "Authorization: Basic dXNlcjo=" \
  -H "Connect-Protocol-Version: 1" \
  -H "Content-Type: application/json" \
  -d '{"path": "/tmp/hello.txt"}'

List a Directory

Request Path

http
POST /filesystem.Filesystem/ListDir

Request Parameters

ParameterTypeRequiredDescription
pathstringYesDirectory path
depthintegerNoRecursive depth

Response Fields

FieldTypeDescription
entriesEntryInfo[]Directory contents

Request Example

bash
curl -X POST "$ENVD_API_BASE/filesystem.Filesystem/ListDir" \
  -H "X-Access-Token: $ENVD_ACCESS_TOKEN" \
  -H "Authorization: Basic dXNlcjo=" \
  -H "Connect-Protocol-Version: 1" \
  -H "Content-Type: application/json" \
  -d '{"path": "/tmp", "depth": 1}'

Create a Directory

Request Path

http
POST /filesystem.Filesystem/MakeDir

Request Parameters

ParameterTypeRequiredDescription
pathstringYesDirectory path

Returns the created EntryInfo on success.

Move a File or Directory

Request Path

http
POST /filesystem.Filesystem/Move

Request Parameters

ParameterTypeRequiredDescription
sourcestringYesSource path
destinationstringYesDestination path

Returns the moved EntryInfo on success.

Delete a File or Directory

Request Path

http
POST /filesystem.Filesystem/Remove

Request Parameters

ParameterTypeRequiredDescription
pathstringYesFile or directory path

Returns an empty object on success.

Watch Directory Changes

Request Path

http
POST /filesystem.Filesystem/WatchDir

Request Parameters

ParameterTypeRequiredDescription
pathstringYesDirectory path
recursivebooleanNoWhether to recursively watch subdirectories

Event Types

EventDescription
EVENT_TYPE_CREATEFile or directory created
EVENT_TYPE_WRITEFile written
EVENT_TYPE_REMOVEFile or directory deleted
EVENT_TYPE_RENAMEFile or directory renamed
EVENT_TYPE_CHMODPermission changed

Non-Streaming Directory Watchers

If your calling environment cannot conveniently consume streaming responses, use a non-streaming watcher.

Create a Watcher

http
POST /filesystem.Filesystem/CreateWatcher

Request parameters:

ParameterTypeRequiredDescription
pathstringYesDirectory path
recursivebooleanNoWhether to recursively watch

Response fields:

FieldTypeDescription
watcherIdstringWatcher ID

Fetch Events

http
POST /filesystem.Filesystem/GetWatcherEvents

Request parameters:

ParameterTypeRequiredDescription
watcherIdstringYesWatcher ID

Delete a Watcher

http
POST /filesystem.Filesystem/RemoveWatcher

Request parameters:

ParameterTypeRequiredDescription
watcherIdstringYesWatcher ID

Download a File

Request Path

http
GET /files

Request Parameters

ParameterTypeRequiredDescription
pathstringNoFile path. Must be URL-encoded and can be relative to the user's home directory
usernamestringNoUser used to resolve relative paths
signaturestringNoFile access signature. Not required when using X-Access-Token
signature_expirationintegerNoSignature expiration time, as a Unix timestamp in seconds

Returns application/octet-stream file content on success.

Request Example

bash
curl -X GET "$ENVD_API_BASE/files?path=%2Ftmp%2Fhello.txt" \
  -H "X-Access-Token: $ENVD_ACCESS_TOKEN" \
  -o hello.txt

Upload a File

Request Path

http
POST /files

Request Parameters

Query parameters are the same as the download file API. The request body uses multipart/form-data with a field named file.

Returns an array of written EntryInfo objects on success.

Request Example

bash
curl -X POST "$ENVD_API_BASE/files?path=%2Ftmp%2Fhello.txt" \
  -H "X-Access-Token: $ENVD_ACCESS_TOKEN" \
  -F "file=@hello.txt"