Skip to content

One Samba/SMB share. Paths are relative to the root of the share. Each operation opens and closes its own connection, so the session can be used for a long time without keeping a connection alive.

How to get one

  1. Samba .newSession()
  2. SambaSession
local share = Samba.newSession(hostname, username, password, shareName)

Functions

  • listFiles table Lists the names of the entries in a directory of the share that match a search pattern.
  • copyRemoteToLocal self Downloads a file from the share into the project.
  • copyLocalToRemote self Uploads a project file (fetched from the Reflex server first when it is not in the workspace) to the share.
  • removeFile self Deletes a file in the share.
  • close self Releases the SMB client of this session.
share.listFiles(path: string, searchPattern: string)→table

Lists the names of the entries in a directory of the share that match a search pattern. Files and subdirectories are both returned, as names only. SMB servers usually include the special entries "." and "..". Use "" as path for the share root and "*" as pattern for everything.

Parameters

path string
Directory in the share; "" for the root
searchPattern string
Wildcard pattern, for example "*.xlsx" or "*"

Returns

table List of entry names

Example

for _, name in ipairs(share.listFiles("2025", "*.xlsx")) do
print(name)
end
share.copyRemoteToLocal(remoteFile: string, localFile: string)→self

Downloads a file from the share into the project. Missing local folders are created and an existing local file is overwritten. Raises "Failed to copy remote file to local file: ..." on failure.

Parameters

remoteFile string
Path of the file in the share
localFile string
Path in the project to save the file as

Returns

self chainable The share itself, so calls can be chained.

Example

share.copyRemoteToLocal("2025/summary.xlsx", "input/summary.xlsx")
share.copyLocalToRemote(localFile: string, remoteFile: string, overwrite?: boolean)→self

Uploads a project file (fetched from the Reflex server first when it is not in the workspace) to the share. Missing folders on the share are created. When the remote file exists it is replaced only if overwrite is true; otherwise the copy fails.

Parameters

localFile string
Path of the file in the project
remoteFile string
Path in the share to write the file to
overwrite boolean optional
true to replace an existing remote file; default false

Returns

self chainable The share itself, so calls can be chained.

Example

share.copyLocalToRemote("output/report.pdf", "2025/05/report.pdf", true)
share.removeFile(remoteFile: string)→self

Deletes a file in the share. Raises an error when it cannot be deleted.

Parameters

remoteFile string
Path of the file in the share

Returns

self chainable The share itself, so calls can be chained.
share.close()→self

Releases the SMB client of this session. Operations already close their own connection, so this is only housekeeping; do not use the session afterwards.

Returns

self chainable The share itself, so calls can be chained.