Configuring the Application Shared Directory
From API version 23, shared directory configuration is supported. In the application file sharing scenario, you can configure the shared directory scope to prevent sensitive data disclosure.
How to Develop
-
Add the shareFiles tag to the module tag in the application module-level configuration file src/main/module.json5 to restrict permissions for sandbox shared directories. If no shared directory is configured, the application is allowed to share files in its own sandbox by default.
shareFiles tag
{ "module": { // ... "shareFiles": "$profile:share_files", // Resource configuration, which points to the configuration file share_files.json defined in the profile. // ... } } -
Define the configuration file share_files.json under resources/base/profile in the development view to specify the permission information for all shared paths of the current module.
The file name share_files can be changed to any valid file name, but must be the same as the file name configured in the shareFiles tag.
Description of the share_files tag
| Property | Description | Data Type | Mandatory |
|---|---|---|---|
| scopes | Sharing scope. For details, see the description of the scopes tag. | Object array | No |
Description of the scopes tag
| Property | Description | Data Type | Mandatory |
|---|---|---|---|
| path | Shared path. Currently, only the el2 directory is supported. It is unique in scopes. The options are as follows: - /base/files- /base/preferences- /base/haps | string | Mandatory when scopes exists. |
| permission | Shared path permission. The options are as follows: - r: read-only.- r+w: read and write. | string | Mandatory when scopes exists. |
NOTE
If the configuration is modified during an application update, the new configuration takes effect for management, and temporary shared file permissions remain unaffected.
Example of share_files.json:
{
"share_files": {
"scopes": [
{
"path": "/base/files",
"permission": "r+w"
}
]
}
}
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 native-fileshare-guidelines
openharmony 鸿蒙 manage-external-storage-sys
openharmony 鸿蒙 file-persistPermission
openharmony 鸿蒙 app-file-backup-extension
openharmony 鸿蒙 request-dir-permission
openharmony 鸿蒙 user-file-overview
openharmony 鸿蒙 select-user-file
openharmony 鸿蒙 app-file-backup-overview