未验证 提交 6b1c7305 编写于 作者: O openharmony_ci 提交者: Gitee

!5236 【翻译完成】#I58VDA

Merge pull request !5236 from Annie_wang/PR4247
# User File Access and Management
>![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
>**NOTE**<br/>
>
>- The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>- The APIs of this module are system APIs and cannot be called by third-party applications. Currently, these APIs can be called only by **filepicker**.
This module provides service APIs for accessing and managing user files. It interworks with the underlying file management services to implement media library and external card management, and provides capabilities for applications to query and create user files.
## Modules to Import
```js
......@@ -156,7 +158,7 @@ Obtains information about the second-level album or files in asynchronous mode.
## filemanager.createFile
filemanager.createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise&lt;string&gt;
createFile(path : string, filename : string, options? : {dev? : DevInfo}) : Promise&lt;string&gt;
Creates a file in the specified path in asynchronous mode. This API uses a promise to return the result.
......@@ -173,7 +175,7 @@ Creates a file in the specified path in asynchronous mode. This API uses a promi
| Type| Description|
| --- | -- |
| promise<string>| Promise used to return the URI of the file created.|
| Promise&lt;string&gt; | Promise used to return the URI of the file created.|
- Error
| Error Info| Error Code|Description|
......
......@@ -3,7 +3,7 @@
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
This module provides functions related to file security levels. It provides JS APIs to obtain and set file security levels.
The APIs of this module can be used to obtain and set file security levels.
## Modules to Import
......@@ -64,7 +64,7 @@ Sets the security label for a file in asynchronous mode. This API uses a promise
setSecurityLabel(path:string, dataLevel:string, callback: AsyncCallback&lt;void&gt;):void
Sets the security label for a file in asynchronous mode. This API uses an asynchronous callback to return the result.
Sets the security label for a file in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.File.DistributedFile
......@@ -138,7 +138,7 @@ Obtains the security label of a file in asynchronous mode. This API uses a promi
getSecurityLabel(path:string, callback:AsyncCallback&lt;string&gt;): void
Obtains the security label of a file in asynchronous mode. This API uses an asynchronous callback to return the result.
Obtains the security label of a file in asynchronous mode. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.File.DistributedFile
......
# App Storage Statistics
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
>
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
The APIs of this module can be used to obtain storage space information, including the space of built-in and plug-in memory cards, space occupied by different types of data, and space of application data.
## Modules to Import
......@@ -15,10 +17,14 @@ import storagestatistics from "@ohos.storageStatistics";
getTotalSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
Asynchronously obtains the total space of the specified volume. This API uses a promise to return the result.
Asynchronously obtains the total size of the specified volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description|
......@@ -29,7 +35,7 @@ Asynchronously obtains the total space of the specified volume. This API uses a
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the total space of the volume.|
| Promise&lt;number&gt; | Promise used to return the total size of the volume.|
- Example
......@@ -46,16 +52,20 @@ Asynchronously obtains the total space of the specified volume. This API uses a
getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):void
Asynchronously obtains the total space of the specified volume. This API uses a callback to return the result.
Asynchronously obtains the total size of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| volumeUuid | string | Yes | UUID of the volume. |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the volume.|
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total size of the volume.|
- Example
......@@ -75,8 +85,12 @@ getFreeSizeOfVolume(volumeUuid: string): Promise&lt;number&gt;
Asynchronously obtains the available space of the specified volume. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description|
......@@ -107,8 +121,12 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback&lt;number&gt;):vo
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
......@@ -130,21 +148,25 @@ Asynchronously obtains the available space of the specified volume. This API use
getBundleStats(packageName: string): Promise&lt;BundleStats&gt;
Asynchronously obtains app information. This API uses a promise to return the result.
Asynchronously obtains information about an application. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | -------- |
| packageName | string | Yes | Bundle name of the app.|
| packageName | string | Yes | Bundle name of the application.|
- Return value
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the app information.|
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the application information obtained.|
- Example
......@@ -161,16 +183,20 @@ Asynchronously obtains app information. This API uses a promise to return the re
getBundleStats(packageName: string, callback: AsyncCallback&lt;BundleStats&gt;): void
Asynchronously obtains app information. This API uses a callback to return the result.
Asynchronously obtains information about an application. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| packageName | string | Yes | Bundle name of the app.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the app information.|
| packageName | string | Yes | Bundle name of the application.|
| callback | callback:AsyncCallback&lt;[Bundlestats](#bundlestats)&gt; | Yes | Callback invoked to return the application information obtained.|
- Example
......@@ -182,14 +208,310 @@ Asynchronously obtains app information. This API uses a callback to return the r
});
```
## storagestatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(): Promise<BundleStats>
Asynchronously obtains information about the current third-party application. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Return value
| Type | Description |
| ------------------------------------------ | -------------------------- |
| Promise&lt;[Bundlestats](#bundlestats)&gt; | Promise used to return the application information obtained. |
- Example
```js
let bundleStats = await storageStatistics.getCurrentBundleStats();
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
```
## storagestatistics.getCurrentBundleStats<sup>9+</sup>
getCurrentBundleStats(callback: AsyncCallback<BundleStats>): void
Asynchronously obtains information about the current third-party application. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Parameters
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------------------------- | ---- | ------------------------------------ |
| callback | callback:AsyncCallback&lt;[BundleStats](#bundlestats)&gt; | Yes | Callback invoked to return the application information obtained. |
- Example
```js
storagestatistics.getCurrentBundleStats(function(error, bundleStats){
// Do something.
console.info("getCurrentBundleStats successfully:"+ JSON.stringify(bundleStats));
});
```
## BundleStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
### Attributes
- Attribute
| Name | Type | Description |
| --------- | ------ | -------------- |
| appSize | number | Size of the application. |
| cacheSize | number | Cache size of the application. |
| dataSize | number | Total data size of the application.|
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(): Promise<number>
Obtains the total space of the built-in memory card. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Return value
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the total space of the built-in memory card. |
- Example
```js
let number = await storageStatistics.getTotalSize();
console.info("getTotalSize successfully:"+ JSON.stringify(number));
```
## storagestatistics.getTotalSize<sup>9+</sup>
getTotalSize(callback: AsyncCallback<number>): void
Obtains the total space of the built-in memory card. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory | Description |
| -------- | ------------------------------------ | ---- | ------------------------ |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the total space of the built-in memory card.|
- Example
```js
storagestatistics.getTotalSize(function(error, number){
// Do something.
console.info("getTotalSize successfully:"+ JSON.stringify(number));
});
```
## storagestatistics.getFreeSize<sup>9+</sup>
getFreeSize(): Promise<number>
Obtains the available space of the built-in memory card. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Return value
| Type | Description |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | Promise used to return the available space of the built-in memory card.|
- Example
```js
let number = await storageStatistics.getFreeSize();
console.info("getFreeSize successfully:"+ JSON.stringify(number));
```
## storagestatistics.getFreeSize<sup>9+</sup>
getFreeSize(callback: AsyncCallback<number>): void
Obtains the available space of the built-in memory card. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback invoked to return the available space of the built-in memory card.|
- Example
```js
storagestatistics.getFreeSize(function(error, number){
// Do something.
console.info("getFreeSize successfully:"+ JSON.stringify(number));
});
```
## storagestatistics.getSystemSize<sup>9+</sup>
getSystemSize(): Promise&lt;number&gt;
Asynchronously obtains the system space. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Return value
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;number&gt; | Promise used to return the system space obtained.|
- Example
```js
storagestatistics.getSystemSize().then(function(number){
console.info("getSystemSize successfully:"+ number);
}).catch(function(err){
console.info("getSystemSize failed with error:"+ err);
});
```
## storagestatistics.getSystemSize<sup>9+</sup>
getSystemSize(callback:AsyncCallback&lt;number&gt;):void
Asynchronously obtains the system space. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| callback | callback:AsyncCallback&lt;number&gt; | Yes | Callback used to return the system space obtained.|
- Example
```js
storagestatistics.getSystemSize(function(error, number){
// Do something.
console.info("getSystemSize successfully:"+ number);
});
```
## storagestatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string): Promise&lt;StorageStats&gt;
Asynchronously obtains the space occupied by each type of user data. This API uses a promise to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description|
| ---------- | ------ | ---- | ---- |
| userId | string | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried.|
- Return value
| Type | Description |
| --------------------- | ---------------- |
| Promise&lt;[StorageStats](#StorageStats)&gt; | Promise used to return the information obtained.|
- Example
```js
let userId = "";
storagestatistics.getUserStorageStats(userId).then(function(StorageStats){
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
}).catch(function(err){
console.info("getUserStorageStats failed with error:"+ err);
});
```
## storagestatistics.getUserStorageStats<sup>9+</sup>
getUserStorageStats(userId?: string, callback:AsyncCallback&lt;StorageStats&gt;):void
Asynchronously obtains the space occupied by each type of user data. This API uses a callback to return the result.
**Required permissions**: ohos.permission.STORAGE_MANAGER
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
**System API**: This is a system API and cannot be called by third-party applications.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------ | ---- | -------------------------- |
| userId | string | No | User ID.<br>Value:<br>-&nbsp; Set this parameter to the ID of the user to be queried.<br>-&nbsp; If no value is specified, information about the current user is queried. |
| callback | callback:AsyncCallback&lt;[StorageStats](#StorageStats)&gt; | Yes | Callback invoked to return the information obtained.|
- Example
```js
storagestatistics.getUserStorageStats(userId, function(error, StorageStats){
// Do something.
console.info("getUserStorageStats successfully:"+ JSON.stringify(StorageStats));
});
```
## StorageStats<sup>9+</sup>
**System capability**: SystemCapability.FileManagement.StorageService.SpatialStatistics
- Attribute
| Name | Type | Description |
| --------- | ------ | -------------- |
| appSize<sup>9+</sup> | number | Size of the app. |
| cacheSize<sup>9+</sup> | number | Cache size of the app. |
| dataSize<sup>9+</sup> | number | Total data size of the app.|
| total | number | Total space of the built-in memory card. |
| audio | number | Space occupied by the audio data. |
| video | number | Space occupied by the video data.|
| image | number | Space occupied by the image data. |
| file | number | Space occupied by files. |
| app | number | Space occupied by the application data.|
# Volume Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br>
>
> - The initial APIs of this module are supported since API version 9.
> - API version 9 is a canary release for trial use. The APIs of this version may be unstable.
> - API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
The APIs of this module can be used to perform volume and disk management, including obtaining volume information, mounting and unmounting volumes, partitioning disks, and formatting volumes.
## Modules to Import
......@@ -15,7 +18,7 @@ import volumemanager from "@ohos.volumeManager";
getAllVolumes(): Promise&lt;Array&lt;Volume&gt;&gt;
Asynchronously obtains information about all available volumes. This method uses a promise to return the result.
Asynchronously obtains information about all available volumes. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -37,7 +40,7 @@ Asynchronously obtains information about all available volumes. This method uses
getAllVolumes(callback: AsyncCallback&lt;Array&lt;Volume&gt;&gt;): void
Asynchronously obtains information about all available volumes. This method uses a callback to return the result.
Asynchronously obtains information about all available volumes. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -61,7 +64,7 @@ Asynchronously obtains information about all available volumes. This method uses
mount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously mounts a volume. This method uses a promise to return the result.
Asynchronously mounts a volume. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -90,7 +93,7 @@ Asynchronously mounts a volume. This method uses a promise to return the result.
mount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result.
Asynchronously obtains the available space of the specified volume. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -114,7 +117,7 @@ Asynchronously obtains the available space of the specified volume. This method
unmount(volumeId: string): Promise&lt;boolean&gt;
Asynchronously unmounts a volume. This method uses a promise to return the result.
Asynchronously unmounts a volume. This API uses a promise to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......@@ -143,7 +146,7 @@ Asynchronously unmounts a volume. This method uses a promise to return the resul
unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
Asynchronously unmounts a volume. This method uses a callback to return the result.
Asynchronously unmounts a volume. This API uses a callback to return the result.
**System capability**: SystemCapability.FileManagement.StorageService.Volume
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册