fs_read
fs_read(filename) reads a file from the job’s directory and returns its content as a string. Returns nil if the file does not exist.
Signature
Section titled “Signature”fs_read(filename)
asyncParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
filename |
string | File name (relative to job directory) |
Returns
Section titled “Returns”| Value | Type | Description |
|---|---|---|
| content | string / nil | File content, or nil if file does not exist |
Example
Section titled “Example”function before_fetch(request, ctx) local cached = fs_read("last_response.json") if cached then local data = json_decode(cached) request.headers["If-None-Match"] = data.etag end return requestendSee Also
Section titled “See Also”- fs_read_binary - Read binary files
- fs_overwrite - Write file content