From ba51f7a76b8c7035e570803f4b11489c24b182c6 Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Thu, 20 Apr 2023 16:21:59 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/Readme-EN.md | 1 + .../apis/js-apis-file-cloudsyncmanager.md | 142 ++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 en/application-dev/reference/apis/js-apis-file-cloudsyncmanager.md diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index 68f91da67f..69989d5c01 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -233,6 +233,7 @@ - [@ohos.data.ValuesBucket (Value Bucket)](js-apis-data-valuesBucket.md) - File Management + - [@ohos.file.cloudSyncManager (Device-Cloud Synchronization Management)](js-apis-file-cloudsyncmanager.md) - [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md) - [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md) - [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md) diff --git a/en/application-dev/reference/apis/js-apis-file-cloudsyncmanager.md b/en/application-dev/reference/apis/js-apis-file-cloudsyncmanager.md new file mode 100644 index 0000000000..3fa93ccd10 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-file-cloudsyncmanager.md @@ -0,0 +1,142 @@ +# @ohos.file.cloudSyncManager (Device-Cloud Synchronization Management) + +The **cloudSyncManager** module provides APIs for changing the cloud and device service status and notifying the data changes. + +> **NOTE** +> +> - The initial APIs of this module are supported since API version 10. 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. +> - The APIs of this module support processing of error codes. For details, see [File Management Error Codes](../errorcodes/errorcode-filemanagement.md). + +## Modules to Import + +```js +import cloudSyncManager from '@ohos.file.cloudSyncManager'; +``` + +## cloudSyncManager.changeAppCloudSwitch + +changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise<void>; + +Changes the device-cloud file synchronization switch for an application. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSyncManager + +**Parameters** + +| Name | Type | Mandatory| Description| +| ---------- | ------ | ---- | ---- | +| accountId | string | Yes | Account ID.| +| bundleName | string | Yes | Bundle name of the application.| +| status | boolean | Yes | State of the cloud-device file synchronization switch to set. The value **true** means to enable this function; the value **false** means the opposite.| + +**Return value** + +| Type | Description | +| --------------------- | ---------------- | +| Promise<void> | Promise used to return the result.| + +**Example** + + ```js + let accountId = "testAccount"; + let bundleName = "com.example.bundle"; + cloudSyncManager.changeAppCloudSwitch(accountId, bundleName, true).then(function() { + console.info("changeAppCloudSwitch successfully"); + }).catch(function(err) { + console.info("changeAppCloudSwitch failed with error message: " + err.message + ", error code: " + err.code); + }); + ``` + +## cloudSyncManager.changeAppCloudSwitch + +changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback<void>): void; + +Changes the device-cloud file synchronization switch for an application. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSyncManager + +**Parameters** + +| Name | Type | Mandatory| Description| +| ---------- | ------ | ---- | ---- | +| accountId | string | Yes | Account ID.| +| bundleName | string | Yes | Bundle name of the application.| +| status | boolean | Yes | State of the cloud-device file synchronization switch to set. The value **true** means to enable this function; the value **false** means the opposite.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| + +**Example** + + ```js + let accountId = "testAccount"; + let bundleName = "com.example.bundle"; + cloudSyncManager.changeAppCloudSwitch(accountId, bundleName, true, (err) => { + if (err) { + console.info("changeAppCloudSwitch failed with error message: " + err.message + ", error code: " + err.code); + } else { + console.info("changeAppCloudSwitch successfully"); + } + }); + ``` +## cloudSyncManager.notifyDataChange + +notifyDataChange(accountId: string, bundleName: string): Promise<void>; + +Notifies the cloud and device services of the application data change in the cloud. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSyncManager + +**Parameters** + +| Name | Type | Mandatory| Description| +| ---------- | ------ | ---- | ---- | +| accountId | string | Yes | Account ID.| +| bundleName | string | Yes | Bundle name of the application.| + +**Return value** + +| Type | Description | +| --------------------- | ---------------- | +| Promise<void> | Promise used to return the application data change in the cloud.| + +**Example** + + ```js + let accountId = "testAccount"; + let bundleName = "com.example.bundle"; + cloudSyncManager.notifyDataChange(accountId, bundleName).then(function() { + console.info("notifyDataChange successfully"); + }).catch(function(err) { + console.info("notifyDataChange failed with error message: " + err.message + ", error code: " + err.code); + }); + ``` + +## cloudSyncManager.notifyDataChange + +notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback<void>): void; + +Notifies the cloud and device services of the application data change in the cloud. This API uses a promise to return the result. + +**System capability**: SystemCapability.FileManagement.DistributedFileService.CloudSyncManager + +**Parameters** + +| Name | Type | Mandatory| Description| +| ---------- | ------ | ---- | ---- | +| accountId | string | Yes | Account ID.| +| bundleName | string | Yes | Bundle name of the application.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the application data change in the cloud.| + +**Example** + + ```js + let accountId = "testAccount"; + let bundleName = "com.example.bundle"; + cloudSyncManager.notifyDataChange(accountId, bundleName, (err) => { + if (err) { + console.info("notifyDataChange failed with error message: " + err.message + ", error code: " + err.code); + } else { + console.info("notifyDataChange successfully"); + } + }); + ``` -- GitLab