Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
54a694c1
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
54a694c1
编写于
6月 15, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 15, 2023
浏览文件
操作
浏览文件
下载
差异文件
!17811 添加cloudsync api
Merge pull request !17811 from cheny/cloudsync_api
上级
c0e710fb
a6d49799
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
970 addition
and
12 deletion
+970
-12
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+1
-0
zh-cn/application-dev/reference/apis/js-apis-file-cloudsync.md
.../application-dev/reference/apis/js-apis-file-cloudsync.md
+634
-0
zh-cn/application-dev/reference/apis/js-apis-file-cloudsyncmanager.md
...ation-dev/reference/apis/js-apis-file-cloudsyncmanager.md
+286
-11
zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md
...tion-dev/reference/errorcodes/errorcode-filemanagement.md
+49
-1
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
54a694c1
...
...
@@ -263,6 +263,7 @@
-
文件管理
-
[
@ohos.file.backup (备份恢复)
](
js-apis-file-backup.md
)
-
[
@ohos.file.cloudSync (端云同步能力)
](
js-apis-file-cloudsync.md
)
-
[
@ohos.file.cloudSyncManager (端云同步管理)
](
js-apis-file-cloudsyncmanager.md
)
-
[
@ohos.file.environment (目录环境能力)
](
js-apis-file-environment.md
)
-
[
@ohos.file.fileAccess (公共文件访问与管理)
](
js-apis-fileAccess.md
)
...
...
zh-cn/application-dev/reference/apis/js-apis-file-cloudsync.md
0 → 100644
浏览文件 @
54a694c1
# @ohos.file.cloudSync (端云同步能力)
该模块向应用提供端云同步能力,包括启动/停止端云同步以及启动/停止原图下载功能。
> **说明:**
>
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口为系统接口,三方应用不支持调用。
## 导入模块
```
js
import
cloudSync
from
'
@ohos.file.cloudSync
'
```
## SyncState
端云同步状态,为枚举类型。
> **说明:**
>
> 以下同步状态发生变更时,如果应用注册了同步过程事件监听,则通过回调通知应用。
**系统能力**
: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
| 名称 | 值| 描述|
| ----- | ---- | ---- |
| UPLOADING | 0 | 上行同步中 |
| UPLOAD_FAILED | 1 | 上行同步失败 |
| DOWNLOADING | 2 | 下行同步中 |
| DOWNLOAD_FAILED | 3 | 下行同步失败 |
| COMPLETED | 4 | 同步成功 |
| STOPPED | 5 | 同步已停止 |
## ErrorType
端云同步失败类型,为枚举类型。
-
当前阶段,同步过程中,当移动数据网络和WIFI均不可用时,才会返回NETWORK_UNAVAILABLE;若有一种类型网络可用,则能正常同步。
-
同步过程中,非充电场景下,电量低于15%,完成当前批上行同步后停止同步,返回低电量;电量低于10%,完成当前批上行同步后停止同步,返回告警电量。
-
触发同步时,非充电场景下,若电量低于15%,则不允许同步,start接口返回对应错误。
-
上行时,若云端空间不足,则文件上行失败,云端无该文件记录。
-
下行时,若本地空间不足,则文件下行失败,本地空间释放后再次同步会重新下行。
**系统能力**
: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
| 名称 | 值| 描述|
| ----- | ---- | ---- |
| NO_ERROR | 0 | 没有错误 |
| NETWORK_UNAVAILABLE | 1 | 所有网络不可用 |
| WIFI_UNAVAILABLE | 2 | WIFI不可用 |
| BATTERY_LEVEL_LOW | 3 | 低电量(低于15%) |
| BATTERY_LEVEL_WARNING | 4 | 告警电量(低于10%) |
| CLOUD_STORAGE_FULL | 5 | 云端空间不足 |
| LOCAL_STORAGE_FULL | 6 | 本地空间不足 |
## SyncProgress
端云同步过程。
**系统能力**
: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| state |
[
SyncState
](
#syncstate
)
| 是 | 枚举值,端云同步状态|
| error |
[
ErrorType
](
#errortype
)
| 是 | 枚举值,同步失败错误类型|
## GallerySync
云图同步对象,用来支撑图库应用媒体资源端云同步流程。在使用前,需要先创建GallerySync实例。
### constructor
constructor()
端云同步流程的构造函数,用于获取GallerySync类的实例。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
()
```
### on
on(evt: 'progress', callback: (pg: SyncProgress) => void): void
添加同步过程事件监听。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| evt | string | 是 | 订阅的事件类型,取值为'progress'(同步过程事件) |
| callback | (pg: SyncProgress) => void | 是 | 同步过程事件回调,回调入参为
[
SyncProgress
](
#syncprogress
)
, 返回值为void|
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
();
gallerySync
.
on
(
'
progress
'
,
(
pg
:
SyncProgress
)
=>
{
console
.
info
(
"
syncState:
"
+
pg
.
syncState
);
});
```
### off
off(evt: 'progress'): void
移除同步过程事件监听。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| evt | string | 是 | 取消订阅的事件类型,取值为'progress'(同步过程事件)|
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
();
gallerySync
.
on
(
'
progress
'
,
(
pg
:
SyncProgress
)
=>
{
console
.
info
(
"
syncState:
"
+
pg
.
syncState
);
});
gallerySync
.
off
(
'
progress
'
);
```
### start
start(): Promise
<
void
>
异步方法启动端云同步, 以Promise形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回启动端云同步的结果 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 22400001 | Cloud status not ready. |
| 22400002 | Network unavailable. |
| 22400003 | Battery level warning. |
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
();
gallerySync
.
on
(
'
progress
'
,
(
pg
:
SyncProgress
)
=>
{
console
.
info
(
"
syncState:
"
+
pg
.
syncState
);
});
gallerySync
.
start
().
then
(
function
()
{
console
.
info
(
"
start sync successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
start sync failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
### start
start(callback: AsyncCallback
<
void
>
): void
异步方法启动端云同步, 以callback形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| callback | AsyncCallback
<
void
>
| 是 | 异步启动端云同步的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 22400001 | Cloud status not ready. |
| 22400002 | Network unavailable. |
| 22400003 | Battery level warning. |
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
();
gallerySync
.
start
((
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
start sync failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
start sync successfully
"
);
}
});
```
### stop
stop(): Promise
<
void
>
异步方法停止端云同步, 以Promise形式返回结果。
> **说明:**
>
> 调用stop接口,同步流程会停止。再次调用[start](#start)接口会继续同步。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回停止端云同步的结果 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
();
gallerySync
.
stop
().
then
(
function
()
{
console
.
info
(
"
stop sync successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
stop sync failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
### stop
stop(callback: AsyncCallback
<
void
>
): void
异步方法停止端云同步, 以callback形式返回结果。
> **说明:**
>
> 调用stop接口,同步流程会停止。再次调用[start](#start)接口会继续同步。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| callback | AsyncCallback
<
void
>
| 是 | 异步停止端云同步的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
gallerySync
=
new
cloudSync
.
GallerySync
();
gallerySync
.
stop
((
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
stop sync failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
stop sync successfully
"
);
}
});
```
## State
云文件下载状态,为枚举类型。
**系统能力**
: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
| 名称 | 值| 描述|
| ----- | ---- | ---- |
| RUNNING | 0 | 云文件正在下载中 |
| COMPLETED | 1 | 云文件下载完成 |
| FAILED | 2 | 云文件下载失败 |
| STOPPED | 3 | 云文件下载已停止 |
## DownloadProgress
云文件下载过程。
**系统能力**
: SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
| 名称 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| state |
[
State
](
#state
)
| 是 | 枚举值,云文件下载状态|
| processed | number | 是 | 已下载数据大小|
| size | number | 是 | 当前云文件大小|
| uri | string | 是 | 当前云文件uri|
## Download
云文件下载对象,用来支撑图库应用原图文件下载流程。在使用前,需要先创建Download实例。
### constructor
constructor()
云文件下载流程的构造函数,用于获取Download类的实例。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
()
```
### on
on(evt: 'progress', callback: (pg: DownloadProgress) => void): void
添加云文件下载过程事件监听。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| evt | string | 是 | 订阅的事件类型,取值为'progress'(下载过程事件)|
| callback | (pg: DownloadProgress) => void | 是 | 云文件下载过程事件回调,回调入参为
[
DownloadProgress
](
#downloadprogress
)
, 返回值为void|
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
();
download
.
on
(
'
progress
'
,
(
pg
:
DownloadProgress
)
=>
{
console
.
info
(
"
download state:
"
+
pg
.
state
);
});
```
### off
off(evt: 'progress'): void
移除云文件下载过程事件监听。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| evt | string | 是 | 取消订阅的事件类型,取值为'progress'(下载过程事件)|
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13600001 | IPC error. |
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
();
download
.
on
(
'
progress
'
,
(
pg
:
DownloadProgress
)
=>
{
console
.
info
(
"
download state:
"
+
pg
.
state
);
});
download
.
off
(
'
progress
'
);
```
### start
start(): Promise
<
void
>
异步方法启动云文件下载, 以Promise形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回启动云文件下载的结果 |
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
();
download
.
on
(
'
progress
'
,
(
pg
:
DownloadProgress
)
=>
{
console
.
info
(
"
download state:
"
+
pg
.
state
);
});
download
.
start
().
then
(
function
()
{
console
.
info
(
"
start download successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
start download failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13900002 | No such file or directory. |
| 13900025 | No space left on device. |
### start
start(callback: AsyncCallback
<
void
>
): void
异步方法启动云文件下载, 以callback形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| callback | AsyncCallback
<
void
>
| 是 | 异步启动云文件下载的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
| 13900002 | No such file or directory. |
| 13900025 | No space left on device. |
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
();
download
.
start
((
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
start download failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
start download successfully
"
);
}
});
```
### stop
stop(): Promise
<
void
>
异步方法停止云文件下载, 以Promise形式返回结果。
> **说明:**
>
> 调用stop接口, 当前文件下载流程会终止, 缓存文件会被删除,再次调用start接口会重新开始下载
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回停止云文件下载的结果 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
();
download
.
stop
().
then
(
function
()
{
console
.
info
(
"
stop download successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
stop download failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
### stop
stop(callback: AsyncCallback
<
void
>
): void
异步方法停止云文件下载, 以callback形式返回结果。
> **说明:**
>
> 调用stop接口, 当前文件下载流程会终止, 缓存文件会被删除, 再次调用start接口会重新开始下载
**需要权限**
:ohos.permission.CLOUDFILE_SYNC
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSync.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| callback | AsyncCallback
<
void
>
| 是 | 异步停止云文件下载的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
download
=
new
cloudSync
.
Download
();
download
.
stop
((
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
stop download failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
stop download successfully
"
);
}
});
```
zh-cn/application-dev/reference/apis/js-apis-file-cloudsyncmanager.md
浏览文件 @
54a694c1
# @ohos.file.cloudSyncManager (端云同步管理能力)
该模块向云空间
提供通知或更改端云服务状态的能力
。
该模块向云空间
应用提供端云同步管理能力,包括使能/去使能端云协同能力、修改应用同步开关,云端数据变化通知以及帐号退出清理/保留云相关文件等
。
> **说明:**
>
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口为系统接口,三方应用不支持调用。
## 导入模块
```
js
import
cloudSyncManager
from
'
@ohos.file.cloudSyncManager
'
;
import
cloudSyncManager
from
'
@ohos.file.cloudSyncManager
'
```
## cloudSyncManager.changeAppCloudSwitch
changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise
<
void
>
;
changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise
<
void
>
异步方法修改应用的端云文件同步开关,以Promise形式返回结果。
...
...
@@ -24,7 +25,7 @@ changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Pr
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号|
| accountId | string | 是 | 帐号
Id
|
| bundleName | string | 是 | 应用包名|
| status | boolean | 是 | 修改的应用云同步开关状态,true为打开,false为关闭|
...
...
@@ -37,6 +38,7 @@ changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Pr
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
...
...
@@ -57,7 +59,7 @@ changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Pr
## cloudSyncManager.changeAppCloudSwitch
changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback
<
void
>
): void
;
changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback
<
void
>
): void
异步方法修改应用的端云文件同步开关,以callback形式返回结果。
...
...
@@ -67,7 +69,7 @@ changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, cal
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号|
| accountId | string | 是 | 帐号
Id
|
| bundleName | string | 是 | 应用包名|
| status | boolean | 是 | 修改的应用云同步开关状态,true为打开,false为关闭|
| callback | AsyncCallback
<
void
>
| 是 | 异步修改应用的端云文件同步开关之后的回调 |
...
...
@@ -75,6 +77,7 @@ changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, cal
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
...
...
@@ -97,7 +100,7 @@ changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, cal
## cloudSyncManager.notifyDataChange
notifyDataChange(accountId: string, bundleName: string): Promise
<
void
>
;
notifyDataChange(accountId: string, bundleName: string): Promise
<
void
>
异步方法通知端云服务应用的云数据变更,以Promise形式返回结果。
...
...
@@ -107,7 +110,7 @@ notifyDataChange(accountId: string, bundleName: string): Promise<void>;
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号|
| accountId | string | 是 | 帐号
Id
|
| bundleName | string | 是 | 应用包名|
**返回值:**
...
...
@@ -119,6 +122,7 @@ notifyDataChange(accountId: string, bundleName: string): Promise<void>;
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
...
...
@@ -139,7 +143,7 @@ notifyDataChange(accountId: string, bundleName: string): Promise<void>;
## cloudSyncManager.notifyDataChange
notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback
<
void
>
): void
;
notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback
<
void
>
): void
异步方法通知端云服务应用的云数据变更,以callback形式返回结果。
...
...
@@ -149,13 +153,14 @@ notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback&
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号|
| accountId | string | 是 | 帐号
Id
|
| bundleName | string | 是 | 应用包名|
| callback | AsyncCallback
<
void
>
| 是 | 异步通知端云服务应用的云数据变更之后的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
...
...
@@ -174,4 +179,274 @@ notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback&
console
.
info
(
"
notifyDataChange successfully
"
);
}
});
```
\ No newline at end of file
```
## cloudSyncManager.enableCloud
enableCloud(accountId: string, switches: { [bundleName: string]: boolean }): Promise
<
void
>
异步方法使能端云协同能力,以Promise形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC_MANAGER
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号Id|
| switches | object | 是 | 应用的端云协同特性使能开关,bundleName为应用包名,开关状态是个boolean类型|
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回使能端云协同能力的结果 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
accountId
=
"
testAccount
"
;
let
switches
=
{
"
com.example.bundleName1
"
:
true
,
"
com.example.bundleName2
"
:
false
};
cloudSyncManager
.
enableCloud
(
accountId
,
switches
).
then
(
function
()
{
console
.
info
(
"
enableCloud successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
enableCloud failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
## cloudSyncManager.enableCloud
enableCloud(accountId: string, switches: { [bundleName: string]: boolean }, callback: AsyncCallback
<
void
>
): void
异步方法使能端云协同能力,以callback形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC_MANAGER
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号Id|
| switches | object | 是 | 应用的端云协同特性使能开关,bundleName为应用包名,开关状态是个boolean类型|
| callback | AsyncCallback
<
void
>
| 是 | 异步使能端云协同能力之后的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
accountId
=
"
testAccount
"
;
let
switches
=
{
"
com.example.bundleName1
"
:
true
,
"
com.example.bundleName2
"
:
false
};
cloudSyncManager
.
enableCloud
(
accountId
,
switches
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
enableCloud failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
enableCloud successfully
"
);
}
});
```
## cloudSyncManager.disableCloud
disableCloud(accountId: string): Promise
<
void
>
异步方法去使能端云协同能力,以Promise形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC_MANAGER
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号Id|
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回去使能端云协同能力的结果 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
accountId
=
"
testAccount
"
;
cloudSyncManager
.
disableCloud
(
accountId
).
then
(
function
()
{
console
.
info
(
"
disableCloud successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
disableCloud failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
## cloudSyncManager.disableCloud
disableCloud(accountId: string, callback: AsyncCallback
<
void
>
): void
异步方法去使能端云协同能力,以callback形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC_MANAGER
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号Id|
| callback | AsyncCallback
<
void
>
| 是 | 异步去使能端云协同能力之后的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
accountId
=
"
testAccount
"
;
cloudSyncManager
.
disableCloud
(
accountId
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
disableCloud failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
disableCloud successfully
"
);
}
});
```
## Action
清理本地云相关数据时的Action,为枚举类型。
**系统能力**
: SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
| 名称 | 值| 描述|
| ----- | ---- | ---- |
| RETAIN_DATA | 0 | 仅清除云端标识,保留本地缓存文件|
| CLEAR_DATA | 1 | 清除云端标识信息,若存在本地缓存文件,一并删除|
## cloudSyncManager.clean
clean(accountId: string, appActions: { [bundleName: string]: Action }): Promise
<
void
>
异步方法清理本地云相关数据,以Promise形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC_MANAGER
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号Id|
| appActions | object | 是 | 清理动作类型,bundleName为待清理应用包名,
[
Action
](
#action
)
为清理动作类型|
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------------- |
| Promise
<
void
>
| 使用Promise形式返回清理本地云相关数据的结果 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
accountId
=
"
testAccount
"
;
let
appActions
=
{
"
com.example.bundleName1
"
:
cloudSyncManager
.
Action
.
RETAIN_DATA
,
"
com.example.bundleName2
"
:
cloudSyncManager
.
Action
.
CLEAR_DATA
};
cloudSyncManager
.
clean
(
accountId
,
appActions
).
then
(
function
()
{
console
.
info
(
"
clean successfully
"
);
}).
catch
(
function
(
err
)
{
console
.
info
(
"
clean failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
});
```
## cloudSyncManager.clean
clean(accountId: string, appActions: { [bundleName: string]: Action }, callback: AsyncCallback
<
void
>
): void
异步方法去使能端云协同能力,以callback形式返回结果。
**需要权限**
:ohos.permission.CLOUDFILE_SYNC_MANAGER
**系统能力**
:SystemCapability.FileManagement.DistributedFileService.CloudSyncManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---- |
| accountId | string | 是 | 帐号Id|
| appActions | object | 是 | 清理动作类型,bundleName为待清理应用包名,
[
Action
](
#action
)
为清理动作类型|
| callback | AsyncCallback
<
void
>
| 是 | 异步去使能端云协同能力之后的回调 |
**错误码:**
以下错误码的详细介绍请参见
[
文件管理子系统错误码
](
../errorcodes/errorcode-filemanagement.md
)
。
| 错误码ID | 错误信息 |
| ---------------------------- | ---------- |
| 201 | Permission verification failed. |
| 202 | The caller is not a system application. |
| 401 | The input parameter is invalid. |
**示例:**
```
js
let
accountId
=
"
testAccount
"
;
let
appActions
=
{
"
com.example.bundleName1
"
:
cloudSyncManager
.
Action
.
RETAIN_DATA
,
"
com.example.bundleName2
"
:
cloudSyncManager
.
Action
.
CLEAR_DATA
};
cloudSyncManager
.
clean
(
accountId
,
appActions
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
clean failed with error message:
"
+
err
.
message
+
"
, error code:
"
+
err
.
code
);
}
else
{
console
.
info
(
"
clean successfully
"
);
}
});
```
zh-cn/application-dev/reference/errorcodes/errorcode-filemanagement.md
浏览文件 @
54a694c1
...
...
@@ -4,7 +4,7 @@
>
> 以下仅介绍本模块特有错误码,通用错误码请参考[通用错误码说明文档](errorcode-universal.md)。
文件管理子系统错误码由
四部分组成,分别是
[
基础文件IO错误码
](
#基础文件io错误码
)
、
[
用户数据管理错误码
](
#用户数据管理错误码
)
、
[
公共文件访问错误码
](
#公共文件访问错误码
)
和
[
空间统计错误码
](
#空间统计错误码
)
组成
。
文件管理子系统错误码由
五部分组成,分别是
[
基础文件IO错误码
](
#基础文件io错误码
)
、
[
用户数据管理错误码
](
#用户数据管理错误码
)
、
[
公共文件访问错误码
](
#公共文件访问错误码
)
、
[
空间统计错误码
](
#空间统计错误码
)
和
[
端云同步错误码
](
#端云同步错误码
)
。
## 基础文件IO错误码
...
...
@@ -921,3 +921,51 @@ Fail to notify agent
**处理步骤**
检查client是否异常。
## 端云同步错误码
### 22400001 云端状态未ready
**错误信息**
Cloud status not ready
**可能原因**
1.
未启用云。
2.
应用云同步开关未打开。
**处理步骤**
1.
检查是否帐号登录。
2.
检查云同步开关是否打开。
### 22400002 网络不可用
**错误信息**
Network unavailable
**可能原因**
设备未联网或网络不可用。
**处理步骤**
检查网络状态。
### 22400003 告警电量
**错误信息**
Battery level warning
**可能原因**
电量过低。
**处理步骤**
充电状态或电量恢复后再执行。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录