Skip to content
Drive Management

Drive Management

Drive Management is a file storage with folders, versions and access control, comparable to a network share. Your code works with files through use cases; the UI component uidrive.Drive and the page uidrive.PageDrive add a file browser with upload, download, preview, rename and move.

Enable

import cfgdrive "go.wdy.de/nago/application/drive/cfg"

drives := std.Must(cfgdrive.Enable(cfg)) // cfgdrive.Management

cfgdrive.Management has the fields UseCases drive.UseCases and Pages uidrive.Pages. The system registers no page and no admin card; mount the file browser yourself:

cfg.RootViewWithDecoration("files", func(wnd core.Window) core.View {
	return uidrive.PageDrive(wnd, drives.UseCases)
})

PageDrive opens the drive nago.drive of the current user, or the folder given by the query parameter fid.

Drives and access control

A drive is a named root folder. OpenDrive opens or creates it, either private to a user (drive.NamespacePrivate) or global (drive.NamespaceGlobal). Every file has an owner, a group and a Unix-like file mode (drive.OtherRead, drive.OtherWrite, …). In addition, GrantFileAccess grants single users or groups access to a file; these grants are stored in ReBAC and drive files show up as a resource in its editor.

Use cases

Use caseDescription
OpenDriveOpens or creates a drive.
ReadDrivesLists the drives visible to a user.
FindDriveFinds the drive of a file.
StatReads the metadata of a file.
MkDirCreates a folder, or returns an existing one.
PutCreates a file or adds a new version.
GetOpens a version of a file, the latest by default.
ZipZips files on the fly.
WalkDirWalks a folder tree.
RenameRenames a file.
MoveMoves a file into another folder and keeps its ID, history and grants.
DeleteDeletes a file, optionally recursive.
GrantFileAccess, RevokeFileAccess, ReadFileGrantsManage the access grants of a file.

Files are downloaded through /api/nago/v1/drive/file?fid=<id>, which checks the read permission.

Permissions

PermissionAllows to
nago.drive.open_fileopen files
nago.drive.mkdircreate folders
nago.drive.putcreate or update files
nago.drive.renamerename files
nago.drive.deletedelete files and folders
These permissions apply to all drives when granted globally, which equals root access. Prefer the owner, group and file mode, or grant them per file.

Related