--- title: "FileSystem" hideTitleOnPage: true --- ## FileSystemService ### Constructors #### Constructor ```ts new FileSystemService( transport: HttpTransport, fileUrlSigner?: FileUrlSigner): FileSystemService; ``` **Parameters**: - `transport` _HttpTransport_ - `fileUrlSigner?` _FileUrlSigner_ **Returns**: - `FileSystemService` ### Methods #### chmod() ```ts chmod(path: string, permissions: FilePermissionsOptions): Promise; ``` **Parameters**: - `path` _string_ - `permissions` _FilePermissionsOptions_ **Returns**: - `Promise` #### downloadFile() ```ts downloadFile( remotePath: string, localPath: string, options: DownloadFileOptions = {}): Promise; ``` Stream a sandbox file to disk via an exclusive random temp file in the destination directory, renaming on success. Progress callback errors are swallowed. Node.js only. **Parameters**: - `remotePath` _string_ - `localPath` _string_ - `options` _DownloadFileOptions = \{\}_ **Returns**: - `Promise` #### find() ```ts find(path: string, pattern: string): Promise>; ``` **Parameters**: - `path` _string_ - `pattern` _string_ **Returns**: - `Promise>` #### list() ```ts list(path: string, options: { depth?: number } = {}): Promise>; ``` List a directory; response always has `{items,nextCursor}`. **Parameters**: - `path` _string_ - `options` _\{ depth?: number \} = \{\}_ **Returns**: - `Promise>` #### mkdir() ```ts mkdir(path: string, options: { mode?: string } = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _\{ mode?: string \} = \{\}_ **Returns**: - `Promise` #### move() ```ts move(source: string, destination: string): Promise; ``` **Parameters**: - `source` _string_ - `destination` _string_ **Returns**: - `Promise` #### presignedDownloadUrl() ```ts presignedDownloadUrl(path: string, options: PresignedUrlOptions = {}): Promise; ``` Pre-signed download URL for a sandbox file. The signature is minted by the control plane; `expiresInSeconds` must be between 1 and `SIGNED_FILE_MAX_TTL_SECONDS` (7 days). **Parameters**: - `path` _string_ - `options` _PresignedUrlOptions = \{\}_ **Returns**: - `Promise` #### presignedUploadUrl() ```ts presignedUploadUrl(path: string, options: PresignedUrlOptions = {}): Promise; ``` Pre-signed upload URL for a sandbox file. The signature is minted by the control plane; `expiresInSeconds` must be between 1 and `SIGNED_FILE_MAX_TTL_SECONDS` (7 days). **Parameters**: - `path` _string_ - `options` _PresignedUrlOptions = \{\}_ **Returns**: - `Promise` #### read() ```ts read(path: string, _options: ReadFileOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `_options` _ReadFileOptions = \{\}_ **Returns**: - `Promise` #### readMany() ```ts readMany( paths: readonly string[], _options: ReadManyOptions = {}): Promise; ``` **Parameters**: - `paths` _readonly string\[\]_ - `_options` _ReadManyOptions = \{\}_ **Returns**: - `Promise` #### readText() ```ts readText(path: string, options: ReadFileOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _ReadFileOptions = \{\}_ **Returns**: - `Promise` #### replace() ```ts replace( files: string[], pattern: string, newValue: string): Promise>; ``` **Parameters**: - `files` _string\[\]_ - `pattern` _string_ - `newValue` _string_ **Returns**: - `Promise>` #### rm() ```ts rm(path: string, options: { recursive?: boolean } = {}): Promise; ``` **Parameters**: - `path` _string_ - `options` _\{ recursive?: boolean \} = \{\}_ **Returns**: - `Promise` #### search() ```ts search(path: string, pattern: string): Promise>; ``` **Parameters**: - `path` _string_ - `pattern` _string_ **Returns**: - `Promise>` #### stat() ```ts stat(path: string): Promise; ``` **Parameters**: - `path` _string_ **Returns**: - `Promise` #### uploadFile() ```ts uploadFile( localPath: string, remotePath: string, options: UploadFileOptions = {}): Promise; ``` Stream a local file to the sandbox without buffering the full body in memory. Progress callback errors are swallowed. Node.js only. **Parameters**: - `localPath` _string_ - `remotePath` _string_ - `options` _UploadFileOptions = \{\}_ **Returns**: - `Promise` #### watchDir() ```ts watchDir( path: string, onEvent: (event: FilesystemEvent) => void | Promise, options: WatchDirOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `onEvent` _(event: FilesystemEvent) = \> void \| Promise\, options: WatchDirOptions = \{\}_ **Returns**: - `Promise` #### write() ```ts write( path: string, data: string | Uint8Array, options: WriteFileOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `data` _string \| Uint8Array_ - `options` _WriteFileOptions = \{\}_ **Returns**: - `Promise` #### writeMany() ```ts writeMany( files: Record, options: WriteManyOptions = {}): Promise; ``` **Parameters**: - `files` _Record\_ - `options` _WriteManyOptions = \{\}_ **Returns**: - `Promise` #### writeText() ```ts writeText(path: string, text: string, options: WriteFileOptions = {}): Promise; ``` **Parameters**: - `path` _string_ - `text` _string_ - `options` _WriteFileOptions = \{\}_ **Returns**: - `Promise` *** ## FilesystemEventType ```ts enum FilesystemEventType { CREATE = 'create', WRITE = 'write', REMOVE = 'remove', RENAME = 'rename', CHMOD = 'chmod', } ``` **Properties**: - `CREATE` _'create'_ - `WRITE` _'write'_ - `REMOVE` _'remove'_ - `RENAME` _'rename'_ - `CHMOD` _'chmod'_ *** ## DownloadFileOptions **Properties**: - `onProgress?` _TransferProgressCallback_ - `signal?` _AbortSignal_ *** ## FilePermissionsParams ```ts type FilePermissionsParams = FilePermissionsOptions ``` *** ## FilesystemEvent **Properties**: - `type` _FilesystemEventType_ - `name` _string_ - `isDir` _boolean_ - `timestamp` _number_ *** ## Match ```ts type Match = FileMatch ``` *** ## PresignedUrlOptions **Properties**: - `expiresInSeconds?` _number_ *** ## ReadFileOptions *** ## ReadManyOptions *** ## SearchFilesResponse ```ts type SearchFilesResponse = ListResult ``` *** ## TransferProgressCallback *** ## UploadFileOptions **Properties**: - `onProgress?` _TransferProgressCallback_ - `signal?` _AbortSignal_ - `atomic?` _boolean_ *** ## WatchDirOptions **Properties**: - `recursive?` _boolean_ - `onExit?` _(err?: Error) =\> void_ - `onOverflow?` _() =\> void_ *** ## WatchHandle **Properties**: - `exitError` _Error \| undefined_ ### Methods #### stop() ```ts stop(): Promise; ``` **Returns**: - `Promise` #### waitForExit() ```ts waitForExit(): Promise; ``` **Returns**: - `Promise` *** ## WriteFileOptions **Properties**: - `mode?` _string_ - `atomic?` _boolean_ *** ## WriteManyOptions **Properties**: - `atomic?` _boolean_ *** ## SearchResult One page of `GET /sandboxes/search` (`Daytona.search()`). `total` is exact when `totalRelation === 'eq'` and a lower bound when it is `'gte'` (the index caps exact counting at 10 000). **Properties**: - `items` _T\[\]_ - `nextCursor?` _string_ - `total` _number_ - `totalRelation` _SearchTotalRelation_ - `rawTotalRelation` _string_ *** ## SearchSandboxesOptions Every `Daytona.search()` option (`GET /sandboxes/search`). **Properties**: - `q?` _string_ - Free text over name and image; also an exact match when it is a sandbox id. - `status?` _string \| readonly string\[\]_ - A single value or a list (any-of) over the API's lifecycle state names (`running`, `stopped`, ...). - `vmClass?` _VmClass \| readonly VmClass\[\]_ - A single value or a list (any-of). - `region?` _string \| readonly string\[\]_ - A single value or a list (any-of) over region slugs. - `imageRef?` _string_ - `imageRefPrefix?` _string_ - `labels?` _Record\_ - Containment: every listed label must match. - `spot?` _boolean_ - `forkedFrom?` _string_ - Sandboxes forked from this sandbox id. - `minVcpus?` _number_ - `maxVcpus?` _number_ - `minMemoryMib?` _number_ - `maxMemoryMib?` _number_ - `minDiskMib?` _number_ - `maxDiskMib?` _number_ - `createdStartAt?` _SearchTimestamp_ - `createdEndAt?` _SearchTimestamp_ - `updatedStartAt?` _SearchTimestamp_ - `updatedEndAt?` _SearchTimestamp_ - `lastActivityStartAt?` _SearchTimestamp_ - `lastActivityEndAt?` _SearchTimestamp_ - `sort?` _SearchSort_ - Defaults to `created_at`. - `order?` _SearchOrder_ - Defaults to `desc`. - `namePrefix?` _string_ - Server-side prefix on the name (the search form of `list({ name })`). - `idPrefix?` _string_ - Server-side prefix on the id (the search form of `list({ id })`). - `limit?` _number_ - Clamped to 1..200 by the server. - `cursor?` _string_ - Opaque; bound to the filter + sort that produced it. *** ## SearchSort ```ts type SearchSort = 'created_at' | 'updated_at' | 'last_activity_at' | 'name' | 'vcpus' | 'memory_mib' | 'disk_mib' ``` *** ## SearchOrder ```ts type SearchOrder = 'asc' | 'desc' ``` *** ## SearchTimestamp ```ts type SearchTimestamp = Date | string ``` An RFC 3339 string, or a `Date` (serialized with `toISOString()`, i.e. UTC). *** ## SearchTotalRelation ```ts type SearchTotalRelation = (typeof API_SEARCH_TOTAL_RELATIONS)[number] | 'unknown' ``` *** ## FileInfo **Properties**: - `name` _string_ - `path?` _string_ - `isDir` _boolean_ - `size` _number_ - `modTime?` _string_ - `modifiedAt?` _string_ - `mode?` _string_ - `permissions?` _string_ - `owner?` _string_ - `group?` _string_ *** ## FileMatch ```ts type FileMatch = toolbox.Match ``` *** ## ReplaceResult **Properties**: - `file` _string_ - `success?` _boolean_ - `error?` _string_ *** ## FilePermissionsOptions **Properties**: - `mode?` _string_ - `owner?` _string_ - `group?` _string_ *** ## BulkWriteFile **Properties**: - `path` _string_ - `bytes` _number_ *** ## BulkWriteResult **Properties**: - `files` _BulkWriteFile\[\]_ - `errors` _string\[\]_ *** ## BulkReadError **Properties**: - `path` _string_ - `code?` _string_ - `message` _string_ - `source?` _string_ *** ## BulkReadResult **Properties**: - `files` _Record\_ - `errors` _BulkReadError\[\]_ *** ## SIGNED\_FILE\_MAX\_TTL\_SECONDS ```ts const SIGNED_FILE_MAX_TTL_SECONDS = 604_800 ``` Server ceiling on a pre-signed file URL's lifetime (7 days). The API rejects an `expires` further ahead than this, so the SDK refuses it before the request; never-expiring links do not exist.