Light Dark

Types

FileMeta

FileMeta type {
    file-id: Str,
    path: Str,
    size: Int,
    etag: Str?,
    content-type: Str?,
    storage-backend: Str,
    created-at: Int,
    updated-at: Int
}

Metadata about a stored file.

Example

meta file-meta("uploads/image.png")
meta.path          // "uploads/image.png"
meta.size          // 1024
meta.content-type  // "image/png"

Functions

delete-file core

fn (path: Str): Bool

Delete a file and return true if successful.

Example

success delete-file("temp.txt")
// true

file-exists core

fn (path: Str): Bool

Check if a file exists.

Example

file-exists("config.json")  // true or false

file-info core

fn (path: Str): FileMeta

Get metadata information about a file.

Example

info file-info("data.json")
// info.size = 1024
// info.content-type = "application/json"

list-files core

fn (prefix: Str): Vec

List all files matching a prefix path.

Example

files list-files("uploads/")
// ["uploads/image1.png", "uploads/image2.jpg", ...]

read-file core

fn (path: Str): Str

Read the contents of a file and return them as a string.

Example

contents read-file("config.json")
// "{\"debug\": true, \"port\": 8080}"

read-file-bytes core

fn (path: Str): Bytes

Read the contents of a file and return them as bytes.

Example

data read-file-bytes("image.png")
// [137, 80, 78, 71, ...]

write-file core

fn (path: Str, contents: Str): FileMeta

Write a string to a file and return file metadata.

Example

meta write-file("output.txt", "Hello, World!")
// meta.path = "output.txt"
// meta.size = 13

write-file-bytes core

fn (path: Str, contents: Bytes): FileMeta

Write bytes to a file and return file metadata.

Example

data [72, 101, 108, 108, 111]  // "Hello" as bytes
meta write-file-bytes("binary.dat", data)