Keep files in a Shared Folder
A package can keep files in a DSM Shared Folder instead of its data folder; the installer picks (select) or creates (create) one and writes the folder name for your app.
Set it up
Section titled “Set it up”synopkgland init -t native-go --shared-folder select my-appinit takes --shared-folder select|create, --shared-folder-name (create only), --shared-folder-key (default shared) and --shared-folder-permission ro|rw (default rw).
In dsm-package.yaml:
install: sharedFolder: # select or create mode: select # the name your app reads the folder by key: media # ro or rw: the access the package account needs permission: rw # create only: the Shared Folder to create # name: my-app-data| Field | Rule |
|---|---|
mode | select or create |
key | ^[a-z][a-z0-9_]{0,31}$; no pkgwizard_, synopkg or change_ prefix |
permission | ro or rw |
name | create only, forbidden with select. ^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$; system names such as homes, users, volume1 or usbshare1 are refused |
install.sharedFolder declares the folder; install.settings declares the install-wizard inputs (see Manifest). One Shared Folder per project.
What the installer shows
Section titled “What the installer shows”| Mode | Install wizard | Upgrade wizard |
|---|---|---|
select | The NAS’s Shared Folders and a permissions note | The current folder stays unless the administrator checks the change box |
create | A note that the package creates name and grants the package account the permission; an existing folder is kept and only the permission is set | The same note |
With select, DSM grants no access to the chosen folder; an administrator adds the package account (the package’s name) in Control Panel > Shared Folder, Permissions > System internal user. Until then your app reports it as not readable.
With create, uninstalling never deletes the Shared Folder or its files.
Use it
Section titled “Use it”The installer writes config.json to the app’s data folder with the folder name, not its path:
{"schema":1,"shared_folders":{"media":"my-share"}}The Go template resolves the volume path each time, so a moved folder keeps working. Read it with Config.SharedFolders(), or app.ReadSharedFolders and app.ResolveSharedFolder; each reports key, name, path, exists, readable and writable under the DSM ACL. app.status returns them as shared_folders (or shared_folders_error for a damaged config.json) and is administrator-only by default; set "app.status": "authenticated" in backend/internal/api/permissions.json for all signed-in users.
Check permissions before startup
Section titled “Check permissions before startup”Compose apps check the selected bind-mount folders as the package account before starting containers; missing read or write permission stops startup and names the share, package account and Control Panel remedy. Installation can finish first, but the first start still checks; selecting a folder grants nothing.
An admitted DSM launch can show a localized, dismissible permission dialog while the gateway is stopped. Retry only rechecks access; after granting it, start the app in Package Center. It changes no ACLs and starts nothing. An SDK frontend can reuse SharedFolderPermissionDialog; a pass is advisory, since later ACL changes and child-file permissions can still fail I/O.
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Declarations per package | 1 |
| Key | 1 to 32 characters |
| Created folder name | 1 to 32 characters |
init --shared-folder | native-go template only |
| Permission for the package account | ro or rw |
Troubleshooting
Section titled “Troubleshooting”| Symptom or code | Cause | Fix |
|---|---|---|
STANDALONE_SHARED_FOLDER_INVALID | A field breaks a rule above | Fix install.sharedFolder |
INIT_SHARED_FOLDER_INVALID | Invalid init --shared-folder value or template | Fix the option; use -t native-go |
readable or writable is false | The package account lacks access | Grant ro or rw in Control Panel > Shared Folder |
exists is false, shared folder not found on any volume | No volume has that folder | Check that it still exists |
| The error names more than one volume | Two volumes have that folder | Rename one folder |
See Errors for every code.