Skip to content
Talk to our solutions team

Files & Transfer

Filesystem access, archives and moving bytes. Each function lists its parameters, defaults and return value.

File system operations.

Scope: System

FunctionDescription
file.read()Read file contents
file.write()Write content to a file
file.exists()Check if a file or directory exists
file.remove()Remove a file or directory
file.copy()Copy a file
file.move()Move or rename a file
file.mkdir()Create a directory

Read the contents of a file.

ParameterTypeDefaultDescription
pathstringFile path to read (required)
encodingstring"utf-8"Text encoding
FieldTypeDescription
successboolWhether read succeeded
contentstringFile contents
// Read a file
let result = file.read({ path: "/config/settings.json" })
log(result.content)
// Read with home directory expansion
let result = file.read({ path: "~/.ssh/config" })
log(result.content)
// Check success
let result = file.read({ path: "/etc/hostname" })
if (result.success) {
log("Hostname: " + result.content.trim())
}

Write content to a file.

ParameterTypeDefaultDescription
pathstringFile path to write (required)
contentstringContent to write (required)
appendboolfalseAppend instead of overwrite
createbooltrueCreate file if it doesn’t exist
modestring"0644"File permissions (octal)
FieldTypeDescription
successboolWhether write succeeded
// Write a file
file.write({
path: "/tmp/output.txt",
content: "Hello, World!"
})
// Append to a file
file.write({
path: "/var/log/app.log",
content: "New log entry\n",
append: true
})
// Write JSON data
let data = { name: "app", version: "1.0" }
file.write({
path: "/tmp/config.json",
content: JSON.stringify(data, null, 2)
})

Check if a file or directory exists.

ParameterTypeDefaultDescription
pathstringPath to check (required)
FieldTypeDescription
successboolWhether the check succeeded
existsboolWhether the path exists
isDirboolWhether the path is a directory
// Check if a file exists
let result = file.exists({ path: "/config/settings.json" })
if (result.exists) {
log("Config file found")
}
// Check if a directory exists
let result = file.exists({ path: "/app/node_modules" })
if (result.exists && result.isDir) {
log("Dependencies installed")
}

Remove a file or directory.

ParameterTypeDefaultDescription
pathstringPath to remove (required)
recursiveboolfalseRemove directories recursively
FieldTypeDescription
successboolWhether removal succeeded
// Remove a file
file.remove({ path: "/tmp/output.txt" })
// Remove a directory recursively
file.remove({ path: "/tmp/build", recursive: true })

Copy a file from source to destination.

ParameterTypeDefaultDescription
sourcestringSource file path (required)
destinationstringDestination file path (required)
overwriteboolfalseOverwrite existing file
FieldTypeDescription
successboolWhether copy succeeded
// Copy a file
file.copy({
source: "/config/template.yaml",
destination: "/config/settings.yaml"
})
// Copy with overwrite
file.copy({
source: "/tmp/new-config.json",
destination: "/app/config.json",
overwrite: true
})

Move or rename a file.

ParameterTypeDefaultDescription
sourcestringSource file path (required)
destinationstringDestination file path (required)
overwriteboolfalseOverwrite existing file
FieldTypeDescription
successboolWhether move succeeded
// Rename a file
file.move({
source: "/tmp/output.txt",
destination: "/tmp/result.txt"
})
// Move with overwrite
file.move({
source: "/tmp/new-config.json",
destination: "/app/config.json",
overwrite: true
})

Create a directory.

ParameterTypeDefaultDescription
pathstringDirectory path to create (required)
recursivebooltrueCreate parent directories as needed
modestring"0755"Directory permissions (octal)
FieldTypeDescription
successboolWhether directory creation succeeded
// Create a directory
file.mkdir({ path: "/tmp/output" })
// Create nested directories
file.mkdir({ path: "/app/data/cache/images" })
// Non-recursive (parent must exist)
file.mkdir({ path: "/app/new-dir", recursive: false })

File pattern matching functions.

Scope: System

FunctionDescription
glob.find()Find files matching a glob pattern

Find files matching a glob pattern.

ParameterTypeDefaultDescription
patternstringGlob pattern to match (required, e.g., "**/*.txt", "*.go")
pathstring"."Base directory to search in
excludearrayPatterns to exclude
filesOnlyboolfalseReturn only files, not directories
dirsOnlyboolfalseReturn only directories, not files
FieldTypeDescription
successboolWhether the search succeeded
matchesarrayArray of matching file paths
// Find all YAML files
let result = glob.find({ pattern: "**/*.yaml" })
log("Found " + result.matches.length + " YAML files")
// Find files in a specific directory
let result = glob.find({
pattern: "*.go",
path: "/app/src"
})
// Exclude patterns
let result = glob.find({
pattern: "**/*.js",
path: "/app",
exclude: ["node_modules/**", "dist/**"]
})
// Files only (no directories)
let result = glob.find({
pattern: "**/*",
path: "/app/config",
filesOnly: true
})
// Directories only
let result = glob.find({
pattern: "*",
path: "/app",
dirsOnly: true
})

Archive extraction and compression functions.

Scope: System

FunctionDescription
archive.extract()Extract an archive file
archive.compress()Create an archive from files or directories

Extract an archive file (tar, tar.gz, tar.bz2, zip).

ParameterTypeDefaultDescription
sourcestringPath to archive file (required)
destinationstringExtraction destination directory (required)
formatstring(auto)Archive format — auto-detected from extension if not specified
stripRootboolfalseRemove root directory from extracted paths
FieldTypeDescription
successboolWhether extraction succeeded
pathstringExtraction destination path
// Extract a tar.gz archive
archive.extract({
source: "/tmp/app-v1.2.tar.gz",
destination: "/opt/app"
})
// Extract with root stripping
archive.extract({
source: "/tmp/release.zip",
destination: "/opt/app",
stripRoot: true
})
// Extract with explicit format
archive.extract({
source: "/tmp/data.archive",
destination: "/data",
format: "tar.gz"
})

Create an archive from files or directories.

ParameterTypeDefaultDescription
sourcestringSingle source path (file or directory)
sourcesarrayArray of source paths (alternative to source)
destinationstringOutput archive path (required)
formatstring(auto)Archive format — auto-detected from extension if not specified
FieldTypeDescription
successboolWhether compression succeeded
pathstringOutput archive path
// Compress a directory
archive.compress({
source: "/app/dist",
destination: "/tmp/app-dist.tar.gz"
})
// Compress multiple sources
archive.compress({
sources: ["/app/dist", "/app/config"],
destination: "/tmp/release.zip"
})
// Explicit format
archive.compress({
source: "/data/output",
destination: "/tmp/data.archive",
format: "tar.gz"
})

Content extraction from structured documents.

Scope: System

FunctionDescription
extract.markdown()Extract content from Markdown documents

Extract structured content from Markdown documents — code blocks by language, sections by heading, or specific matches by index.

ParameterTypeDefaultDescription
contentstringInline Markdown content to extract from
filestringFile path to read content from
globstringGlob pattern for multiple files
selectstringCSS/path selector to narrow extraction
languagestringFilter code blocks by language
headingstringFilter sections by heading text
indexintSelect a specific match by index

At least one of content, file, or glob is required.

FieldTypeDescription
successboolWhether extraction succeeded
contentstringExtracted content
blocksarrayExtracted code blocks (when filtering by language)
// Extract code blocks by language
let result = extract.markdown({
content: readmeContent,
language: "yaml"
})
log("Found " + result.blocks.length + " YAML blocks")
// Extract section by heading
let section = extract.markdown({
file: "./docs/README.md",
heading: "Getting Started"
})
log(section.content)
// Extract from file with language filter
let config = extract.markdown({
file: "./docs/guide.md",
language: "json",
index: 0
})
log("First JSON block: " + config.content)
// Extract from multiple files
let results = extract.markdown({
glob: "./docs/**/*.md",
heading: "Installation"
})
log(results.content)

Rsync file synchronization functions. Shells out to the local rsync binary (must be on PATH, or set via rsyncPath) and threads SSH transport parameters through -e ssh ....

Scope: Network

FunctionDescription
rsync.push()Sync a local path to a remote host (local → remote)
rsync.pull()Sync a remote path to a local path (remote → local)
rsync.sync()Push or pull based on a direction parameter

All three functions accept the same parameter map.

ParameterTypeDefaultDescription
hoststringRemote host (required)
userstringSSH username
portint22SSH port
keyPathstringPath to private key file
jumpHoststringJump/bastion host
jumpUserstringJump host username
jumpPortint22Jump host SSH port
jumpKeyPathstringJump host private key path
sshCommandstringCustom ssh command — overrides keyPath/port/jumpHost when set
rsyncPathstring"rsync"Path to the rsync binary
ParameterTypeDefaultDescription
localPathstringLocal file or directory (required)
remotePathstringRemote file or directory (required)
directionstring"push""push" or "pull" — used by rsync.sync() only
ParameterTypeDefaultDescription
archiveboolfalseArchive mode (-a) — recursive + symlinks + perms + times + owner + group + devices
compressboolfalseCompress during transfer (-z)
verboseboolfalseVerbose output (-v)
progressboolfalseShow transfer progress (--progress)
deleteboolfalseDelete extraneous files at the destination (--delete)
dryRunboolfalseTrial run, no changes (-n)
recursiveboolfalseRecursive (-r). Implied by archive
preservePermsboolfalsePreserve permissions (-p). Implied by archive
preserveTimesboolfalsePreserve modification times (-t). Implied by archive
preserveOwnerboolfalsePreserve owner (-o). Implied by archive
preserveGroupboolfalsePreserve group (-g). Implied by archive
checksumboolfalseCompare with checksums instead of mtime+size (-c)
partialboolfalseKeep partially-transferred files (--partial)
partialDirstringDirectory for partial files (--partial-dir)
bandwidthLimitint0Bandwidth cap in KB/s (--bwlimit)
timeoutint0I/O timeout in seconds (--timeout)
ParameterTypeDescription
excludestring[]Patterns passed via --exclude
includestring[]Patterns passed via --include
excludeFromstringFile of exclude patterns (--exclude-from)
includeFromstringFile of include patterns (--include-from)
ParameterTypeDescription
extraArgsstring[]Additional arguments appended to the rsync command line
FieldTypeDescription
successboolWhether the sync succeeded
bytesSentintBytes sent to the remote
bytesReceivedintBytes received from the remote
filesTransferredintNumber of files transferred
totalFilesintTotal files considered
outputstringCaptured stdout
errorOutputstringCaptured stderr
exitCodeintrsync exit code
errorstringError message when success is false
let result = rsync.push({
host: "web.example.com",
user: "deploy",
keyPath: "~/.ssh/id_rsa",
localPath: "./dist/",
remotePath: "/var/www/html/",
archive: true,
compress: true,
delete: true
})
log("Sent " + result.bytesSent + " bytes")
rsync.pull({
host: "db.example.com",
user: "backup",
keyPath: "~/.ssh/backup_key",
remotePath: "/var/backups/db/",
localPath: "./backups/",
archive: true,
progress: true
})
let preview = rsync.push({
host: "prod.example.com",
user: "deploy",
keyPath: "~/.ssh/prod_key",
localPath: "./src/",
remotePath: "/srv/app/",
archive: true,
delete: true,
dryRun: true,
exclude: ["*.log", "node_modules/", ".git/"],
include: ["*.config.js"]
})
log(preview.output)
rsync.push({
host: "10.0.5.20",
user: "deploy",
keyPath: "~/.ssh/internal_key",
jumpHost: "bastion.example.com",
jumpUser: "jumper",
jumpKeyPath: "~/.ssh/bastion_key",
localPath: "./release/",
remotePath: "/opt/release/",
archive: true
})
rsync.push({
host: "host.example.com",
sshCommand: "ssh -o StrictHostKeyChecking=yes -o UserKnownHostsFile=~/.ssh/prod_known_hosts -i ~/.ssh/prod_key",
localPath: "./dist/",
remotePath: "/srv/app/",
archive: true
})
function syncTree(dir) {
return rsync.sync({
host: "host.example.com",
user: "deploy",
keyPath: "~/.ssh/id_rsa",
localPath: "./tree/",
remotePath: "/var/tree/",
archive: true,
direction: dir // "push" or "pull"
})
}
rsync.push({
host: "remote.example.com",
user: "ops",
keyPath: "~/.ssh/id_rsa",
localPath: "./large-dataset/",
remotePath: "/data/",
archive: true,
bandwidthLimit: 1024, // 1 MB/s cap
partial: true,
partialDir: ".rsync-partial"
})

SCP file transfer functions. Built on the standalone registry/scp package which adds jump-host (ProxyJump) chains, strict host key checking, and explicit authMethod selection on top of the basic SCP transport.

For a connection-less single-call SCP that piggybacks on the SSH namespace’s client, see ssh.upload / ssh.download. Use the scp namespace when you need jump hosts, agent auth selection, or known_hosts verification.

Scope: Network

FunctionDescription
scp.upload()Upload a local file or directory to a remote host
scp.download()Download a remote file or directory to the local host
scp.transfer()Upload or download based on a direction parameter

All three functions accept the same parameter map.

ParameterTypeDefaultDescription
hoststringRemote host or host:port (required)
userstringSSH username (required)
passwordstringPassword for password auth
keyPathstringPath to private key file
keyPassphrasestringPassphrase for an encrypted private key
authMethodstringinferred"key", "password", or "agent". Inferred from credentials when omitted
timeoutint120Connection timeout in seconds
strictHostKeyCheckingboolfalseVerify the host key against known_hosts
knownHostsPathstringPath to a known_hosts file
jumpHostsarrayOrdered list of jump/bastion hosts; see below
ParameterTypeDefaultDescription
localPathstringLocal file or directory (required)
remotePathstringRemote file or directory (required)
recursiveboolfalseCopy directories recursively
preserveModeboolfalsePreserve file permissions and timestamps
directionstring"upload""upload" or "download" — used by scp.transfer() only

jumpHosts is an array of map entries. Each entry accepts:

FieldTypeDescription
hoststringJump host host or host:port
userstringSSH username on the jump host
passwordstringPassword for password auth
keyPathstringPath to private key file
keyPassphrasestringPassphrase for the private key
authMethodstring"key", "password", or "agent"

Hosts are dialed in order. The final SSH connection to host is tunnelled through every jump host in sequence.

When strictHostKeyChecking: true, every hop — including every jump host — is verified against the same known_hosts file. When strictHostKeyChecking is left off, both the target and the jump hosts skip verification.

FieldTypeDescription
successboolWhether the transfer succeeded
bytesTransferredintTotal bytes transferred
filesTransferredintNumber of files transferred (multi-file when recursive: true)
errorstringError message when success is false
let result = scp.upload({
host: "server.example.com",
user: "deploy",
keyPath: "~/.ssh/id_rsa",
localPath: "./dist/app.tar.gz",
remotePath: "/tmp/app.tar.gz"
})
log("Uploaded " + result.bytesTransferred + " bytes")
scp.download({
host: "server.example.com",
user: "deploy",
keyPath: "~/.ssh/id_rsa",
remotePath: "/etc/myapp/",
localPath: "./backup/config/",
recursive: true,
preserveMode: true
})
scp.upload({
host: "10.0.5.20", // private-network target
user: "deploy",
keyPath: "~/.ssh/internal_key",
jumpHosts: [
{
host: "bastion.example.com:22",
user: "jumper",
keyPath: "~/.ssh/bastion_key"
}
],
localPath: "./release.tar.gz",
remotePath: "/opt/releases/release.tar.gz"
})
scp.upload({
host: "prod.example.com",
user: "deploy",
keyPath: "~/.ssh/prod_key",
strictHostKeyChecking: true,
knownHostsPath: "~/.ssh/known_hosts",
localPath: "./build/server",
remotePath: "/usr/local/bin/server",
preserveMode: true
})
function syncArtifact(dir) {
return scp.transfer({
host: "server.example.com",
user: "deploy",
keyPath: "~/.ssh/id_rsa",
localPath: "./artifact.bin",
remotePath: "/var/cache/artifact.bin",
direction: dir // "upload" or "download"
})
}

S3-compatible storage functions.

Scope: Network

FunctionDescription
s3.upload()Upload files to S3
s3.download()Download files from S3
s3.list()List objects in S3
s3.delete()Delete objects from S3

All functions require these connection parameters:

ParameterTypeDefaultDescription
endpointstringS3 endpoint URL (required)
accessKeystringAccess key ID (required)
secretKeystringSecret access key (required)
bucketstringBucket name (required)
secureboolfalseUse HTTPS
insecureSkipVerifyboolfalseSkip TLS certificate verification

Upload files or directories to S3.

ParameterTypeDefaultDescription
sourcestringLocal file/directory path (required)
destinationstringS3 object key/prefix (required)
recursivebooltrueUpload directories recursively
FieldTypeDescription
successboolWhether upload succeeded
uploadedintNumber of files uploaded
// Upload a file
s3.upload({
endpoint: "s3.amazonaws.com",
accessKey: "AKIAIOSFODNN7EXAMPLE",
secretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
bucket: "my-bucket",
secure: true,
source: "/tmp/backup.tar.gz",
destination: "backups/backup.tar.gz"
})
// Upload a directory (MinIO)
s3.upload({
endpoint: "minio.local:9000",
accessKey: "minioadmin",
secretKey: "minioadmin",
bucket: "artifacts",
source: "/app/dist/",
destination: "releases/v1.0/",
recursive: true
})

Download files from S3.

ParameterTypeDefaultDescription
objectstringS3 object key to download (required)
pathstringLocal destination path (required)
FieldTypeDescription
successboolWhether download succeeded
downloadedintNumber of files downloaded
// Download a file
s3.download({
endpoint: "s3.amazonaws.com",
accessKey: "AKIAIOSFODNN7EXAMPLE",
secretKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
bucket: "my-bucket",
secure: true,
object: "backups/backup.tar.gz",
path: "/tmp/backup.tar.gz"
})

List objects in an S3 bucket.

ParameterTypeDefaultDescription
prefixstringFilter objects by prefix
FieldTypeDescription
successboolWhether listing succeeded
objectsarrayArray of objects with name, size, modTime, isDir
// List all objects
let result = s3.list({
endpoint: "minio.local:9000",
accessKey: "minioadmin",
secretKey: "minioadmin",
bucket: "artifacts"
})
for (let obj of result.objects) {
log(obj.name + " (" + obj.size + " bytes)")
}
// List with prefix filter
let result = s3.list({
endpoint: "minio.local:9000",
accessKey: "minioadmin",
secretKey: "minioadmin",
bucket: "artifacts",
prefix: "releases/v1.0/"
})

Delete objects from S3.

ParameterTypeDefaultDescription
pathstringObject key or prefix to delete (required)
recursiveboolfalseDelete all objects with the given prefix
FieldTypeDescription
successboolWhether deletion succeeded
deletedintNumber of objects deleted
// Delete a single object
s3.delete({
endpoint: "minio.local:9000",
accessKey: "minioadmin",
secretKey: "minioadmin",
bucket: "artifacts",
path: "old-release.tar.gz"
})
// Delete all objects with prefix
s3.delete({
endpoint: "minio.local:9000",
accessKey: "minioadmin",
secretKey: "minioadmin",
bucket: "artifacts",
path: "releases/v0.9/",
recursive: true
})

Azure Blob storage functions.

Scope: Network

FunctionDescription
azureblob.upload()Upload files to Azure Blob Storage
azureblob.download()Download files from Azure Blob Storage
azureblob.list()List blobs in a container
azureblob.delete()Delete blobs from Azure Blob Storage

Upload files or directories to Azure Blob Storage with parallel processing and incremental sync support.

ParameterTypeDefaultDescription
connectionStringstringAzure storage connection string (required)
maxRetriesint3Maximum retry attempts
maxWorkersint4Concurrent upload workers
incrementalboolfalseOnly upload changed files
continueOnErrorbooltrueContinue on individual file errors
syncModestringSync mode: "fast" or "hash"
containerstringBlob container name (required)
sourcestringLocal file/directory path (required)
destinationstringBlob prefix/path (required)
recursivebooltrueUpload directories recursively
skipPatternsarrayPatterns to skip
FieldTypeDescription
successboolWhether upload succeeded
uploadedintNumber of files uploaded
skippedintNumber of files skipped
// Upload a directory
azureblob.upload({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "assets",
source: "/app/dist/",
destination: "releases/v1.0/"
})
// Incremental upload (only changed files)
azureblob.upload({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "static",
source: "/app/public/",
destination: "web/",
incremental: true,
syncMode: "hash",
skipPatterns: ["*.tmp", ".DS_Store"]
})

Download files from Azure Blob Storage.

ParameterTypeDefaultDescription
connectionStringstringAzure storage connection string (required)
maxRetriesint3Maximum retry attempts
maxWorkersint4Concurrent download workers
incrementalboolfalseOnly download changed files
continueOnErrorbooltrueContinue on individual file errors
containerstringBlob container name (required)
prefixstringBlob prefix to download
destinationstringLocal destination path (required)
skipPatternsarrayPatterns to skip
FieldTypeDescription
successboolWhether download succeeded
downloadedintNumber of files downloaded
skippedintNumber of files skipped
// Download all blobs with prefix
azureblob.download({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "backups",
prefix: "db/daily/",
destination: "/tmp/restore/"
})
// Incremental download
azureblob.download({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "assets",
prefix: "images/",
destination: "/app/public/images/",
incremental: true
})

List blobs in an Azure Blob Storage container.

ParameterTypeDefaultDescription
connectionStringstringAzure storage connection string (required)
containerstringBlob container name (required)
prefixstringBlob prefix to filter
FieldTypeDescription
successboolWhether listing succeeded
blobsarrayArray of blobs with name, size, lastModified, contentType
// List all blobs in container
let result = azureblob.list({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "assets"
})
for (let blob of result.blobs) {
log(blob.name + " (" + blob.size + " bytes, " + blob.contentType + ")")
}
// List with prefix filter
let result = azureblob.list({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "assets",
prefix: "images/"
})

Delete blobs from Azure Blob Storage.

ParameterTypeDefaultDescription
connectionStringstringAzure storage connection string (required)
containerstringBlob container name (required)
prefixstringBlob prefix to delete
blobNamestringSpecific blob name to delete
FieldTypeDescription
successboolWhether deletion succeeded
deletedintNumber of blobs deleted
// Delete a specific blob
azureblob.delete({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "assets",
blobName: "old-file.txt"
})
// Delete all blobs with prefix
azureblob.delete({
connectionString: "DefaultEndpointsProtocol=https;AccountName=...",
container: "temp",
prefix: "uploads/2023/"
})