namespaces

fs

Read and write UTF-8 files on the local filesystem of the running server.

The fs namespace reads and writes UTF-8 files on the local filesystem of the server process. For durable application data, use db or doc. Reach for fs only for local files such as a template or an export.

Operations

File operations are fallible, so guard them with rescue:

marreta
contents = fs.read(path) rescue { error: "could not read" }
NameSignatureSummary
fs.readfs.read(path)Reads a UTF-8 file.
fs.writefs.write(path, content)Writes a UTF-8 file and returns the content.
fs.appendfs.append(path, content)Appends UTF-8 content to a file.
fs.existsfs.exists(path)Returns whether a file exists.
fs.deletefs.delete(path)Deletes a file and returns whether it existed.

Notes

  • These operations touch the server’s local disk, which is not shared across instances and may be ephemeral. Do not use fs as your source of truth.
  • read, write, append, and delete can fail (missing file, permissions). Wrap them in rescue.