Skip to content

File Operations

File operations are one‑shot devwork actions that create, read, update, delete, and move files on the device’s USB file system. All local paths may include a directory prefix (e.g., /cfg/config.json).

Important: The devwork envelope must wrap actions in an "actions" array:

{
"devwork": {
"actions": [
{ "a": "fcre", "p": { "file": "/config.json", "content": { "key": "value" } } }
]
}
}
ActionDescription
fdldDownload a file from a URL
fcreCreate a file with optional content
fappAppend content to a file
fmvMove / rename a file
fdelDelete a file or directory
fmkdCreate a directory
ffmtFormat the entire USB filesystem
fgetRetrieve a file or directory listing

Downloads a file from a URL and saves it to the local filesystem. A temporary file in /tmp is used during the download; on success it is renamed to the target path.

Configuration variables

  • a (Required, string): Must be fdld.
  • p (Required, object):
ParameterTypeRequiredDescription
urlstringyesHTTP/HTTPS URL to fetch
filestringyesLocal path to save to (parent directories must exist)

Response: The device sends an uplink message on completion.

FieldTypeDescription
filestringLocal file path
resnumber0 = OK, 1 = timeout, 2 = internal error, 3 = server error
httpresnumberHTTP status code (if available)
httplennumberContent length from the HTTP server
{
"devwork": {
"actions": [
{
"a": "fdld",
"p": {
"url": "https://example.com/config.json",
"file": "/cfg/config.json"
}
}
]
}
}

Creates a file with optional content. Any existing file at that path is discarded before writing.

Configuration variables

  • a (Required, string): Must be fcre.
  • p (Required, object):
ParameterTypeRequiredDescription
filestringyesLocal path to create
contentstring or objectnoInitial file content
{
"devwork": {
"actions": [
{ "a": "fcre", "p": { "file": "/notes.txt", "content": "hello" } }
]
}
}

Appends content to an existing file.

Configuration variables

  • a (Required, string): Must be fapp.
  • p (Required, object):
ParameterTypeRequiredDescription
filestringyesLocal path to append to
contentstringyesData to append
{
"devwork": {
"actions": [
{ "a": "fapp", "p": { "file": "/notes.txt", "content": " world" } }
]
}
}

Moves or renames a file. The source and destination may be in different directories.

Configuration variables

  • a (Required, string): Must be fmv.
  • p (Required, object):
ParameterTypeRequiredDescription
srcstringyesCurrent file path
dststringyesNew file path
{
"devwork": {
"actions": [
{ "a": "fmv", "p": { "src": "/tmp/temp.json", "dst": "/cfg/live.json" } }
]
}
}

Deletes a file or directory.

Configuration variables

  • a (Required, string): Must be fdel.
  • p (Required, object):
ParameterTypeRequiredDescription
pathstringyesLocal file or directory to delete
{
"devwork": {
"actions": [
{ "a": "fdel", "p": { "path": "/notes.txt" } }
]
}
}

Creates a new directory.

Configuration variables

  • a (Required, string): Must be fmkd.
  • p (Required, object):
ParameterTypeRequiredDescription
pathstringyesDirectory path to create
{
"devwork": {
"actions": [
{ "a": "fmkd", "p": { "path": "/cfg" } }
]
}
}

Formats the entire USB filesystem. This wipes all files and directories.

Configuration variables

  • a (Required, string): Must be ffmt.
  • p (Required, object):
ParameterTypeRequiredDescription
confstringyesMust be "YES" (confirmation string)
{
"devwork": {
"actions": [
{ "a": "ffmt", "p": { "conf": "YES" } }
]
}
}

Retrieves a file’s contents or a directory listing. The device responds with an uplink message.

Configuration variables

  • a (Required, string): Must be fget.
  • p (Required, object):
ParameterTypeRequiredDescription
pathstringyesLocal file or directory path
ascbooleannoStrip non‑ASCII bytes from file content
hexbooleannoSend file content as a hex string

Response: The device sends an uplink message: { "devwork": { "fs": { "fget": { "isFile": true|false, "path": "<path>", "content": <file content or directory JSON> } } } }

Files larger than ~1 KB may be truncated in the JSON response.

{
"devwork": {
"actions": [
{ "a": "fget", "p": { "path": "/cfg/config.json" } }
]
}
}