pocketenv/files

Manage files stored inside a sandbox.

Files are written into the sandbox filesystem and can be listed or deleted.

Types

Metadata for a file stored in a sandbox.

pub type File {
  File(id: String, path: String, created_at: String)
}

Constructors

  • File(id: String, path: String, created_at: String)

Values

pub fn delete(
  sb: sandbox.ConnectedSandbox,
  id: String,
) -> Result(Nil, pocketenv.PocketenvError)

Deletes the file identified by id.

pub fn file_decoder() -> decode.Decoder(File)

JSON decoder for File.

pub fn list(
  sb: sandbox.ConnectedSandbox,
) -> Result(List(File), pocketenv.PocketenvError)

Lists all files in the sandbox.

Example

let assert Ok(files) = sb |> files.list()
pub fn write(
  sb: sandbox.ConnectedSandbox,
  path: String,
  content: String,
) -> Result(Nil, pocketenv.PocketenvError)

Writes (or overwrites) a file at path with content.

Example

let assert Ok(Nil) = sb |> files.write("/app/.env", "PORT=8080\n")
Search Document