1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"), 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit CoreFileKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * Provides the capabilities to control cloud file synchronization. 25 * 26 * @namespace cloudSync 27 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 28 * @since arkts{ '1.1':'11','1.2':'20'} 29 * @arkts 1.1&1.2 30 */ 31declare namespace cloudSync { 32 /** 33 * Describes the Sync state type. 34 * 35 * @enum { number } 36 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 37 * @since arkts{ '1.1':'12','1.2':'20'} 38 * @arkts 1.1&1.2 39 */ 40 enum SyncState { 41 /** 42 * Indicates that the sync state is uploading. 43 * 44 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 45 * @since arkts{ '1.1':'12','1.2':'20'} 46 * @arkts 1.1&1.2 47 */ 48 UPLOADING = 0, 49 /** 50 * Indicates that the sync failed in upload processing. 51 * 52 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 53 * @since arkts{ '1.1':'12','1.2':'20'} 54 * @arkts 1.1&1.2 55 */ 56 UPLOAD_FAILED = 1, 57 /** 58 * Indicates that the sync state is downloading. 59 * 60 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 61 * @since arkts{ '1.1':'12','1.2':'20'} 62 * @arkts 1.1&1.2 63 */ 64 DOWNLOADING = 2, 65 /** 66 * Indicates that the sync failed in download processing. 67 * 68 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 69 * @since arkts{ '1.1':'12','1.2':'20'} 70 * @arkts 1.1&1.2 71 */ 72 DOWNLOAD_FAILED = 3, 73 /** 74 * Indicates that the sync finish. 75 * 76 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 77 * @since arkts{ '1.1':'12','1.2':'20'} 78 * @arkts 1.1&1.2 79 */ 80 COMPLETED = 4, 81 /** 82 * Indicates that the sync has been stopped. 83 * 84 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 85 * @since arkts{ '1.1':'12','1.2':'20'} 86 * @arkts 1.1&1.2 87 */ 88 STOPPED = 5, 89 } 90 91 /** 92 * Describes the Sync Error type. 93 * 94 * @enum { number } 95 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 96 * @since arkts{ '1.1':'12','1.2':'20'} 97 * @arkts 1.1&1.2 98 */ 99 enum ErrorType { 100 /** 101 * No error occurred. 102 * 103 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 104 * @since arkts{ '1.1':'12','1.2':'20'} 105 * @arkts 1.1&1.2 106 */ 107 NO_ERROR = 0, 108 /** 109 * Synchronization aborted due to network unavailable. 110 * 111 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 112 * @since arkts{ '1.1':'12','1.2':'20'} 113 * @arkts 1.1&1.2 114 */ 115 NETWORK_UNAVAILABLE = 1, 116 /** 117 * Synchronization aborted due to wifi unavailable. 118 * 119 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 120 * @since arkts{ '1.1':'12','1.2':'20'} 121 * @arkts 1.1&1.2 122 */ 123 WIFI_UNAVAILABLE = 2, 124 /** 125 * Synchronization aborted due to low capacity level. 126 * 127 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 128 * @since arkts{ '1.1':'12','1.2':'20'} 129 * @arkts 1.1&1.2 130 */ 131 BATTERY_LEVEL_LOW = 3, 132 /** 133 * Synchronization aborted due to warning low capacity level. 134 * 135 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 136 * @since arkts{ '1.1':'12','1.2':'20'} 137 * @arkts 1.1&1.2 138 */ 139 BATTERY_LEVEL_WARNING = 4, 140 /** 141 * Synchronization aborted due to cloud storage is full. 142 * 143 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 144 * @since arkts{ '1.1':'12','1.2':'20'} 145 * @arkts 1.1&1.2 146 */ 147 CLOUD_STORAGE_FULL = 5, 148 /** 149 * Synchronization aborted due to local storage is full. 150 * 151 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 152 * @since arkts{ '1.1':'12','1.2':'20'} 153 * @arkts 1.1&1.2 154 */ 155 LOCAL_STORAGE_FULL = 6, 156 /** 157 * Synchronization aborted due to device temperature is too high. 158 * 159 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 160 * @since arkts{ '1.1':'12','1.2':'20'} 161 * @arkts 1.1&1.2 162 */ 163 DEVICE_TEMPERATURE_TOO_HIGH = 7, 164 /** 165 * Synchronization aborted due to remote server is abnormal. 166 * 167 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 168 * @since 20 169 * @arkts 1.1&1.2 170 */ 171 REMOTE_SERVER_ABNORMAL = 8, 172 173 } 174 175 /** 176 * The SyncProgress data structure. 177 * 178 * @interface SyncProgress 179 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 180 * @since arkts{ '1.1':'12','1.2':'20'} 181 * @arkts 1.1&1.2 182 */ 183 interface SyncProgress { 184 /** 185 * The current sync state. 186 * 187 * @type { SyncState } 188 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 189 * @since arkts{ '1.1':'12','1.2':'20'} 190 * @arkts 1.1&1.2 191 */ 192 state: SyncState; 193 /** 194 * The error type of sync. 195 * 196 * @type { ErrorType } 197 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 198 * @since arkts{ '1.1':'12','1.2':'20'} 199 * @arkts 1.1&1.2 200 */ 201 error: ErrorType; 202 } 203 204 /** 205 * GallerySync object. 206 * 207 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 208 * @systemapi 209 * @since arkts{ '1.1':'10','1.2':'20'} 210 * @arkts 1.1&1.2 211 */ 212 class GallerySync { 213 /** 214 * A constructor used to create a GallerySync object. 215 * 216 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 217 * @systemapi 218 * @since arkts{ '1.1':'10','1.2':'20'} 219 * @arkts 1.1&1.2 220 */ 221 constructor(); 222 /** 223 * Subscribes to sync progress change event. This method uses a callback to get sync progress changes. 224 * 225 * @permission ohos.permission.CLOUDFILE_SYNC 226 * @param { 'progress' } evt - event type. 227 * @param { function } callback - callback function with a `SyncProgress` argument. 228 * @throws { BusinessError } 201 - Permission verification failed. 229 * @throws { BusinessError } 202 - The caller is not a system application. 230 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 231 * <br>2.Incorrect parameter types. 232 * @throws { BusinessError } 13600001 - IPC error 233 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 234 * @systemapi 235 * @since arkts{ '1.1':'10','1.2':'20'} 236 * @arkts 1.1&1.2 237 */ 238 on(evt: 'progress', callback: (pg: SyncProgress) => void): void; 239 /** 240 * Unsubscribes from sync progress event. 241 * 242 * @permission ohos.permission.CLOUDFILE_SYNC 243 * @param { 'progress' } evt - event type. 244 * @param { function } callback - callback function with a `SyncProgress` argument. 245 * @throws { BusinessError } 201 - Permission verification failed. 246 * @throws { BusinessError } 202 - The caller is not a system application. 247 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 248 * <br>2.Incorrect parameter types. 249 * @throws { BusinessError } 13600001 - IPC error 250 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 251 * @systemapi 252 * @since arkts{ '1.1':'10','1.2':'20'} 253 * @arkts 1.1&1.2 254 */ 255 off(evt: 'progress', callback: (pg: SyncProgress) => void): void; 256 /** 257 * Unsubscribes all callbacks objects from sync progress event. 258 * 259 * @permission ohos.permission.CLOUDFILE_SYNC 260 * @param { 'progress' } evt - event type. 261 * @throws { BusinessError } 201 - Permission verification failed. 262 * @throws { BusinessError } 202 - The caller is not a system application. 263 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 264 * <br>2.Incorrect parameter types. 265 * @throws { BusinessError } 13600001 - IPC error 266 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 267 * @systemapi 268 * @since arkts{ '1.1':'10','1.2':'20'} 269 * @arkts 1.1&1.2 270 */ 271 off(evt: 'progress'): void; 272 /** 273 * Start the gallery sync task. 274 * 275 * @permission ohos.permission.CLOUDFILE_SYNC 276 * @returns { Promise<void> } - Return Promise. 277 * @throws { BusinessError } 201 - Permission verification failed. 278 * @throws { BusinessError } 202 - The caller is not a system application. 279 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 280 * @throws { BusinessError } 22400001 - Cloud status not ready. 281 * @throws { BusinessError } 22400002 - Network unavailable. 282 * @throws { BusinessError } 22400003 - Low battery level. 283 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 284 * @systemapi 285 * @since arkts{ '1.1':'10','1.2':'20'} 286 * @arkts 1.1&1.2 287 */ 288 start(): Promise<void>; 289 /** 290 * Start the gallery sync task with callback. 291 * 292 * @permission ohos.permission.CLOUDFILE_SYNC 293 * @param { AsyncCallback<void> } [callback] - Callback function. 294 * @throws { BusinessError } 201 - Permission verification failed. 295 * @throws { BusinessError } 202 - The caller is not a system application. 296 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 297 * <br>2.Incorrect parameter types. 298 * @throws { BusinessError } 22400001 - Cloud status not ready. 299 * @throws { BusinessError } 22400002 - Network unavailable. 300 * @throws { BusinessError } 22400003 - Low battery level. 301 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 302 * @systemapi 303 * @since arkts{ '1.1':'10','1.2':'20'} 304 * @arkts 1.1&1.2 305 */ 306 start(callback: AsyncCallback<void>): void; 307 /** 308 * Stop the gallery sync task. 309 * 310 * @permission ohos.permission.CLOUDFILE_SYNC 311 * @returns { Promise<void> } - Return Promise. 312 * @throws { BusinessError } 201 - Permission verification failed. 313 * @throws { BusinessError } 202 - The caller is not a system application. 314 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 315 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 316 * @systemapi 317 * @since arkts{ '1.1':'10','1.2':'20'} 318 * @arkts 1.1&1.2 319 */ 320 stop(): Promise<void>; 321 /** 322 * Stop the gallery sync task with callback. 323 * 324 * @permission ohos.permission.CLOUDFILE_SYNC 325 * @param { AsyncCallback<void> } [callback] - Callback function. 326 * @throws { BusinessError } 201 - Permission verification failed. 327 * @throws { BusinessError } 202 - The caller is not a system application. 328 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 329 * <br>2.Incorrect parameter types. 330 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 331 * @systemapi 332 * @since arkts{ '1.1':'10','1.2':'20'} 333 * @arkts 1.1&1.2 334 */ 335 stop(callback: AsyncCallback<void>): void; 336 } 337 338 /** 339 * Describes the State type of download. 340 * 341 * @enum { number } 342 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 343 * @since arkts{ '1.1':'11','1.2':'20'} 344 * @arkts 1.1&1.2 345 */ 346 enum State { 347 /** 348 * Indicates that the download task in process now. 349 * 350 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 351 * @since arkts{ '1.1':'11','1.2':'20'} 352 * @arkts 1.1&1.2 353 */ 354 RUNNING = 0, 355 /** 356 * Indicates that the download task finished. 357 * 358 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 359 * @since arkts{ '1.1':'11','1.2':'20'} 360 * @arkts 1.1&1.2 361 */ 362 COMPLETED = 1, 363 /** 364 * Indicates that the download task failed. 365 * 366 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 367 * @since arkts{ '1.1':'11','1.2':'20'} 368 * @arkts 1.1&1.2 369 */ 370 FAILED = 2, 371 /** 372 * Indicates that the download task stopped. 373 * 374 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 375 * @since arkts{ '1.1':'11','1.2':'20'} 376 * @arkts 1.1&1.2 377 */ 378 STOPPED = 3, 379 } 380 381 /** 382 * Describes the download Error type. 383 * 384 * @enum { number } 385 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 386 * @since arkts{ '1.1':'11','1.2':'20'} 387 * @arkts 1.1&1.2 388 */ 389 enum DownloadErrorType { 390 /** 391 * No error occurred. 392 * 393 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 394 * @since arkts{ '1.1':'11','1.2':'20'} 395 * @arkts 1.1&1.2 396 */ 397 NO_ERROR = 0, 398 /** 399 * download aborted due to unknown error. 400 * 401 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 402 * @since arkts{ '1.1':'11','1.2':'20'} 403 * @arkts 1.1&1.2 404 */ 405 UNKNOWN_ERROR = 1, 406 /** 407 * download aborted due to network unavailable. 408 * 409 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 410 * @since arkts{ '1.1':'11','1.2':'20'} 411 * @arkts 1.1&1.2 412 */ 413 NETWORK_UNAVAILABLE = 2, 414 /** 415 * download aborted due to local storage is full. 416 * 417 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 418 * @since arkts{ '1.1':'11','1.2':'20'} 419 * @arkts 1.1&1.2 420 */ 421 LOCAL_STORAGE_FULL = 3, 422 /** 423 * download aborted due to content is not found in the cloud. 424 * 425 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 426 * @since arkts{ '1.1':'11','1.2':'20'} 427 * @arkts 1.1&1.2 428 */ 429 CONTENT_NOT_FOUND = 4, 430 /** 431 * download aborted due to frequent user requests. 432 * 433 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 434 * @since arkts{ '1.1':'11','1.2':'20'} 435 * @arkts 1.1&1.2 436 */ 437 FREQUENT_USER_REQUESTS = 5, 438 } 439 440 /** 441 * The DownloadProgress data structure. 442 * 443 * @interface DownloadProgress 444 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 445 * @since arkts{ '1.1':'11','1.2':'20'} 446 * @arkts 1.1&1.2 447 */ 448 interface DownloadProgress { 449 /** 450 * The current download state. 451 * 452 * @type { State } 453 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 454 * @since arkts{ '1.1':'11','1.2':'20'} 455 * @arkts 1.1&1.2 456 */ 457 state: State; 458 /** 459 * The processed data size for current file. 460 * 461 * @type { number } 462 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 463 * @since arkts{ '1.1':'11','1.2':'20'} 464 * @arkts 1.1&1.2 465 */ 466 processed: number; 467 /** 468 * The size of current file. 469 * 470 * @type { number } 471 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 472 * @since arkts{ '1.1':'11','1.2':'20'} 473 * @arkts 1.1&1.2 474 */ 475 size: number; 476 /** 477 * The uri of current file. 478 * 479 * @type { string } 480 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 481 * @since arkts{ '1.1':'11','1.2':'20'} 482 * @arkts 1.1&1.2 483 */ 484 uri: string; 485 /** 486 * The error type of download. 487 * 488 * @type { DownloadErrorType } 489 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 490 * @since arkts{ '1.1':'11','1.2':'20'} 491 * @arkts 1.1&1.2 492 */ 493 error: DownloadErrorType; 494 } 495 496 /** 497 * Describes the download file type. 498 * @enum { number } 499 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 500 * @since 20 501 * @arkts 1.1&1.2 502 */ 503 enum DownloadFileType { 504 /** 505 * Content file type. 506 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 507 * @since 20 508 * @arkts 1.1&1.2 509 */ 510 CONTENT = 0, 511 /** 512 * Thumbnail file type. 513 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 514 * @since 20 515 * @arkts 1.1&1.2 516 */ 517 THUMBNAIL = 1, 518 /** 519 * LCD file type. 520 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 521 * @since 20 522 * @arkts 1.1&1.2 523 */ 524 LCD = 2 525 } 526 527 /** 528 * FailedFileInfo struct. 529 * @interface FailedFileInfo 530 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 531 * @since 20 532 * @arkts 1.1&1.2 533 */ 534 interface FailedFileInfo { 535 /** 536 * The uri of the file that failes to be downloaded. 537 * @type { string } 538 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 539 * @since 20 540 * @arkts 1.1&1.2 541 */ 542 uri: string; 543 /** 544 * Error code of the file that failes to be downloaded. 545 * @type { DownloadErrorType } 546 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 547 * @since 20 548 * @arkts 1.1&1.2 549 */ 550 error: DownloadErrorType; 551 } 552 553 /** 554 * MultiDownloadProgress object. 555 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 556 * @since 20 557 * @arkts 1.1&1.2 558 */ 559 class MultiDownloadProgress { 560 /** 561 * The current download state. 562 * @type { State } 563 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 564 * @since 20 565 * @arkts 1.1&1.2 566 */ 567 state: State; 568 /** 569 * The download ID of the batch files. 570 * @type { number } 571 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 572 * @since 20 573 * @arkts 1.1&1.2 574 */ 575 taskId: number; 576 /** 577 * The number of files that downloaded successfully 578 * @type { number } 579 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 580 * @since 20 581 * @arkts 1.1&1.2 582 */ 583 successfulCount: number; 584 /** 585 * The number of files that fail to be downloaded. 586 * @type { number } 587 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 588 * @since 20 589 * @arkts 1.1&1.2 590 */ 591 failedCount: number; 592 /** 593 * Total number of the batch files. 594 * @type { number } 595 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 596 * @since 20 597 * @arkts 1.1&1.2 598 */ 599 totalCount: number; 600 /** 601 * Total size of downloaded files. 602 * @type { number } 603 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 604 * @since 20 605 * @arkts 1.1&1.2 606 */ 607 downloadedSize: number; 608 /** 609 * Total size of the batch files. 610 * @type { number } 611 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 612 * @since 20 613 * @arkts 1.1&1.2 614 */ 615 totalSize: number; 616 /** 617 * The error type of download. 618 * @type { DownloadErrorType } 619 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 620 * @since 20 621 * @arkts 1.1&1.2 622 */ 623 errType: DownloadErrorType; 624 /** 625 * Get the list of files that fail to be downloaded. 626 * @returns { Array<FailedFileInfo> } - Return list of files that fail to be downloaded. 627 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 628 * <br>1.Failed to access the database or execute the SQL statement. 629 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 630 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 631 * @since 20 632 * @arkts 1.1&1.2 633 */ 634 getFailedFiles(): Array<FailedFileInfo>; 635 /** 636 * Get the list of files that are successfully downloaded. 637 * @returns { Array<string> } - Return list of files that are successfully downloaded. 638 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 639 * <br>1.Failed to access the database or execute the SQL statement. 640 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 641 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 642 * @since 20 643 * @arkts 1.1&1.2 644 */ 645 getSuccessfulFiles(): Array<string>; 646 } 647 648 /** 649 * Download object. 650 * 651 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 652 * @systemapi 653 * @since arkts{ '1.1':'10','1.2':'20'} 654 * @arkts 1.1&1.2 655 */ 656 class Download { 657 /** 658 * A constructor used to create a Download object. 659 * 660 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 661 * @systemapi 662 * @since arkts{ '1.1':'10','1.2':'20'} 663 * @arkts 1.1&1.2 664 */ 665 constructor(); 666 /** 667 * Subscribes to download progress change event. This method uses a callback to get download progress changes. 668 * 669 * @permission ohos.permission.CLOUDFILE_SYNC 670 * @param { 'progress' } evt - event type. 671 * @param { function } callback - callback function with a `DownloadProgress` argument. 672 * @throws { BusinessError } 201 - Permission verification failed. 673 * @throws { BusinessError } 202 - The caller is not a system application. 674 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 675 * <br>2.Incorrect parameter types. 676 * @throws { BusinessError } 13600001 - IPC error 677 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 678 * @systemapi 679 * @since arkts{ '1.1':'10','1.2':'20'} 680 * @arkts 1.1&1.2 681 */ 682 on(evt: 'progress', callback: (pg: DownloadProgress) => void): void; 683 /** 684 * Unsubscribes from download progress event. 685 * 686 * @permission ohos.permission.CLOUDFILE_SYNC 687 * @param { 'progress' } evt - event type. 688 * @param { function } callback - callback function with a `DownloadProgress` argument. 689 * @throws { BusinessError } 201 - Permission verification failed. 690 * @throws { BusinessError } 202 - The caller is not a system application. 691 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 692 * <br>2.Incorrect parameter types. 693 * @throws { BusinessError } 13600001 - IPC error 694 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 695 * @systemapi 696 * @since arkts{ '1.1':'10','1.2':'20'} 697 * @arkts 1.1&1.2 698 */ 699 off(evt: 'progress', callback: (pg: DownloadProgress) => void): void; 700 /** 701 * Unsubscribes all callbacks objects from download progress event. 702 * 703 * @permission ohos.permission.CLOUDFILE_SYNC 704 * @param { 'progress' } evt - event type. 705 * @throws { BusinessError } 201 - Permission verification failed. 706 * @throws { BusinessError } 202 - The caller is not a system application. 707 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 708 * <br>2.Incorrect parameter types. 709 * @throws { BusinessError } 13600001 - IPC error 710 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 711 * @systemapi 712 * @since arkts{ '1.1':'10','1.2':'20'} 713 * @arkts 1.1&1.2 714 */ 715 off(evt: 'progress'): void; 716 /** 717 * Start the download task. 718 * 719 * @permission ohos.permission.CLOUDFILE_SYNC 720 * @param { string } uri - uri of file. 721 * @returns { Promise<void> } - Return Promise. 722 * @throws { BusinessError } 201 - Permission verification failed. 723 * @throws { BusinessError } 202 - The caller is not a system application. 724 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 725 * <br>2.Incorrect parameter types. 726 * @throws { BusinessError } 13900002 - No such file or directory. 727 * @throws { BusinessError } 13900025 - No space left on device. 728 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 729 * @systemapi 730 * @since arkts{ '1.1':'10','1.2':'20'} 731 * @arkts 1.1&1.2 732 */ 733 start(uri: string): Promise<void>; 734 /** 735 * Start the download task with callback. 736 * 737 * @permission ohos.permission.CLOUDFILE_SYNC 738 * @param { string } uri - uri of file. 739 * @param { AsyncCallback<void> } [callback] - Callback function. 740 * @throws { BusinessError } 201 - Permission verification failed. 741 * @throws { BusinessError } 202 - The caller is not a system application. 742 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 743 * <br>2.Incorrect parameter types. 744 * @throws { BusinessError } 13900002 - No such file or directory. 745 * @throws { BusinessError } 13900025 - No space left on device. 746 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 747 * @systemapi 748 * @since arkts{ '1.1':'10','1.2':'20'} 749 * @arkts 1.1&1.2 750 */ 751 start(uri: string, callback: AsyncCallback<void>): void; 752 /** 753 * Stop the download task. 754 * 755 * @permission ohos.permission.CLOUDFILE_SYNC 756 * @param { string } uri - uri of file. 757 * @returns { Promise<void> } - Return Promise. 758 * @throws { BusinessError } 201 - Permission verification failed. 759 * @throws { BusinessError } 202 - The caller is not a system application. 760 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 761 * <br>2.Incorrect parameter types. 762 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 763 * @systemapi 764 * @since arkts{ '1.1':'10','1.2':'20'} 765 * @arkts 1.1&1.2 766 */ 767 stop(uri: string): Promise<void>; 768 /** 769 * Stop the download task with callback. 770 * 771 * @permission ohos.permission.CLOUDFILE_SYNC 772 * @param { string } uri - uri of file. 773 * @param { AsyncCallback<void> } [callback] - Callback function. 774 * @throws { BusinessError } 201 - Permission verification failed. 775 * @throws { BusinessError } 202 - The caller is not a system application. 776 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 777 * <br>2.Incorrect parameter types. 778 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 779 * @systemapi 780 * @since arkts{ '1.1':'10','1.2':'20'} 781 * @arkts 1.1&1.2 782 */ 783 stop(uri: string, callback: AsyncCallback<void>): void; 784 } 785 786 /** 787 * FileSync object. 788 * 789 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 790 * @since arkts{ '1.1':'12','1.2':'20'} 791 * @arkts 1.1&1.2 792 */ 793 class FileSync { 794 /** 795 * A constructor used to create a FileSync object. 796 * 797 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 798 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 799 * @since arkts{ '1.1':'12','1.2':'20'} 800 * @arkts 1.1&1.2 801 */ 802 constructor(); 803 /** 804 * A constructor used to create a FileSync object. 805 * 806 * @param { string } bundleName - Name of the bundle that need to synchronize and subscribe the sync progress event. 807 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 808 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 809 * <br>2.Incorrect parameter types. 810 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 811 * @systemapi 812 * @since arkts{ '1.1':'12','1.2':'20'} 813 * @arkts 1.1&1.2 814 */ 815 constructor(bundleName: string); 816 /** 817 * Subscribes to sync progress change event. This method uses a callback to get sync progress changes. 818 * 819 * @param { 'progress' } event - event type. 820 * @param { Callback<SyncProgress> } callback - callback function with a `SyncProgress` argument. 821 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 822 * <br>2.Incorrect parameter types. 823 * @throws { BusinessError } 13600001 - IPC error 824 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 825 * @since arkts{ '1.1':'12','1.2':'20'} 826 * @arkts 1.1&1.2 827 */ 828 on(event: 'progress', callback: Callback<SyncProgress>): void; 829 /** 830 * Unsubscribes from sync progress event. 831 * 832 * @param { 'progress' } event - event type. 833 * @param { Callback<SyncProgress> } [callback] - callback function with a `SyncProgress` argument. 834 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types. 835 * @throws { BusinessError } 13600001 - IPC error 836 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 837 * @since arkts{ '1.1':'12','1.2':'20'} 838 * @arkts 1.1&1.2 839 */ 840 off(event: 'progress', callback?: Callback<SyncProgress>): void; 841 /** 842 * Start the file sync task. 843 * 844 * @returns { Promise<void> } - Return Promise. 845 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 846 * @throws { BusinessError } 13600001 - IPC error. 847 * @throws { BusinessError } 22400001 - Cloud status not ready. 848 * @throws { BusinessError } 22400002 - Network unavailable. 849 * @throws { BusinessError } 22400003 - Low battery level. 850 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 851 * @since arkts{ '1.1':'12','1.2':'20'} 852 * @arkts 1.1&1.2 853 */ 854 start(): Promise<void>; 855 /** 856 * Start the file sync task with callback. 857 * 858 * @param { AsyncCallback<void> } callback - Callback function. 859 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified;2.Incorrect parameter types. 860 * @throws { BusinessError } 13600001 - IPC error. 861 * @throws { BusinessError } 22400001 - Cloud status not ready. 862 * @throws { BusinessError } 22400002 - Network unavailable. 863 * @throws { BusinessError } 22400003 - Low battery level. 864 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 865 * @since arkts{ '1.1':'12','1.2':'20'} 866 * @arkts 1.1&1.2 867 */ 868 start(callback: AsyncCallback<void>): void; 869 /** 870 * Stop the file sync task. 871 * 872 * @returns { Promise<void> } - Return Promise. 873 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 874 * @throws { BusinessError } 13600001 - IPC error. 875 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 876 * @since arkts{ '1.1':'12','1.2':'20'} 877 * @arkts 1.1&1.2 878 */ 879 stop(): Promise<void>; 880 /** 881 * Stop the file sync task with callback. 882 * 883 * @param { AsyncCallback<void> } callback - Callback function. 884 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 885 * <br>2.Incorrect parameter types. 886 * @throws { BusinessError } 13600001 - IPC error. 887 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 888 * @since arkts{ '1.1':'12','1.2':'20'} 889 * @arkts 1.1&1.2 890 */ 891 stop(callback: AsyncCallback<void>): void; 892 /** 893 * Get the last synchronization time. 894 * 895 * @returns { Promise<number> } - Return the date of last synchronization. 896 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 897 * @throws { BusinessError } 13600001 - IPC error. 898 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 899 * @since arkts{ '1.1':'12','1.2':'20'} 900 * @arkts 1.1&1.2 901 */ 902 getLastSyncTime(): Promise<number>; 903 /** 904 * Get the last synchronization time. 905 * 906 * @param { AsyncCallback<number> } callback - Callback function. 907 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 908 * <br>2.Incorrect parameter types. 909 * @throws { BusinessError } 13600001 - IPC error. 910 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 911 * @since arkts{ '1.1':'12','1.2':'20'} 912 * @arkts 1.1&1.2 913 */ 914 getLastSyncTime(callback: AsyncCallback<number>): void; 915 } 916 /** 917 * CloudFileCache object. 918 * 919 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 920 * @since arkts{ '1.1':'11','1.2':'20'} 921 * @arkts 1.1&1.2 922 */ 923 class CloudFileCache { 924 /** 925 * A constructor used to create a CloudFileCache object. 926 * 927 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:Incorrect parameter types. 928 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 929 * @since arkts{ '1.1':'11','1.2':'20'} 930 * @arkts 1.1&1.2 931 */ 932 constructor(); 933 /** 934 * Subscribes to cloud file cache download progress change event. This method uses a callback to get download progress changes. 935 * 936 * @param { 'progress' } event - event type. 937 * @param { Callback<DownloadProgress> } callback - callback function with a `DownloadProgress` argument. 938 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 939 * <br>2.Incorrect parameter types. 940 * @throws { BusinessError } 13600001 - IPC error 941 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 942 * @since arkts{ '1.1':'11','1.2':'20'} 943 * @arkts 1.1&1.2 944 */ 945 on(event: 'progress', callback: Callback<DownloadProgress>): void; 946 /** 947 * Subscribes to a batch of cloud file cache download progress change event. This method uses a callback to get download progress changes. 948 * 949 * @param { 'batchDownload' } event - event type. 950 * @param { Callback<MultiDownloadProgress> } callback - callback function with a `MultiDownloadProgress` argument. 951 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 952 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 953 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 954 * <br>1.Failed to access the database or execute the SQL statement. 955 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 956 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 957 * @since 20 958 * @arkts 1.1&1.2 959 */ 960 on(event: 'batchDownload', callback: Callback<MultiDownloadProgress>): void; 961 /** 962 * Unsubscribes from cloud file cache download progress event. 963 * 964 * @param { 'progress' } event - event type. 965 * @param { Callback<DownloadProgress> } [callback] - callback function with a `DownloadProgress` argument. 966 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 967 * <br>2.Incorrect parameter types. 968 * @throws { BusinessError } 13600001 - IPC error 969 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 970 * @since arkts{ '1.1':'11','1.2':'20'} 971 * @arkts 1.1&1.2 972 */ 973 off(event: 'progress', callback?: Callback<DownloadProgress>): void; 974 /** 975 * Unsubscribes from cloud file cache download progress event. 976 * 977 * @param { 'batchDownload' } event - event type. 978 * @param { Callback<MultiDownloadProgress> } [callback] - callback function with a `MultiDownloadProgress` argument. 979 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 980 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 981 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 982 * <br>1.Failed to access the database or execute the SQL statement. 983 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 984 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 985 * @since 20 986 * @arkts 1.1&1.2 987 */ 988 off(event: 'batchDownload', callback?: Callback<MultiDownloadProgress>): void; 989 /** 990 * Start the cloud file cache download task. 991 * 992 * @param { string } uri - uri of file. 993 * @returns { Promise<void> } - Return Promise. 994 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 995 * <br>2.Incorrect parameter types. 996 * @throws { BusinessError } 13600001 - IPC error. 997 * @throws { BusinessError } 13900002 - No such file or directory. 998 * @throws { BusinessError } 13900025 - No space left on device. 999 * @throws { BusinessError } 14000002 - Invalid URI. 1000 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1001 * @since arkts{ '1.1':'11','1.2':'20'} 1002 * @arkts 1.1&1.2 1003 */ 1004 start(uri: string): Promise<void>; 1005 /** 1006 * Start the cloud file cache download task with callback. 1007 * 1008 * @param { string } uri - uri of file. 1009 * @param { AsyncCallback<void> } callback - Callback function. 1010 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1011 * <br>2.Incorrect parameter types. 1012 * @throws { BusinessError } 13600001 - IPC error. 1013 * @throws { BusinessError } 13900002 - No such file or directory. 1014 * @throws { BusinessError } 13900025 - No space left on device. 1015 * @throws { BusinessError } 14000002 - Invalid URI. 1016 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1017 * @since arkts{ '1.1':'11','1.2':'20'} 1018 * @arkts 1.1&1.2 1019 */ 1020 start(uri: string, callback: AsyncCallback<void>): void; 1021 /** 1022 * Batch start the cloud file cache download task. 1023 * 1024 * @param { Array<string> } uris - The list of uri of file. 1025 * @param { DownloadFileType } [fileType] - download file type. 1026 * @returns { Promise<number> } - Return the downloadId in Promise mode. 1027 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1028 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1029 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1030 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1031 * @throws { BusinessError } 22400004 - Exceed the maximum limit. 1032 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1033 * <br>1.Failed to access the database or execute the SQL statement. 1034 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1035 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1036 * @since 20 1037 * @arkts 1.1&1.2 1038 */ 1039 startBatch(uris: Array<string>, fileType?: DownloadFileType): Promise<number>; 1040 /** 1041 * Stop the cloud file cache download task. 1042 * 1043 * @param { string } uri - uri of file. 1044 * @returns { Promise<void> } - Return Promise. 1045 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1046 * <br>2.Incorrect parameter types. 1047 * @throws { BusinessError } 13600001 - IPC error. 1048 * @throws { BusinessError } 13900002 - No such file or directory. 1049 * @throws { BusinessError } 14000002 - Invalid URI. 1050 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1051 * @since 11 1052 */ 1053 /** 1054 * Stop the cloud file cache download task. 1055 * 1056 * @param { string } uri - uri of file. 1057 * @param { boolean } [needClean] - whether to delete the file that already downloaded. 1058 * @returns { Promise<void> } - Return Promise. 1059 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1060 * <br>2.Incorrect parameter types. 1061 * @throws { BusinessError } 13600001 - IPC error. 1062 * @throws { BusinessError } 13900002 - No such file or directory. 1063 * @throws { BusinessError } 14000002 - Invalid URI. 1064 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1065 * @since arkts{ '1.1':'12','1.2':'20'} 1066 * @arkts 1.1&1.2 1067 */ 1068 stop(uri: string, needClean?: boolean): Promise<void>; 1069 /** 1070 * Stop the cloud file cache download task with callback. 1071 * 1072 * @param { string } uri - uri of file. 1073 * @param { AsyncCallback<void> } callback - Callback function. 1074 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1075 * <br>2.Incorrect parameter types. 1076 * @throws { BusinessError } 13600001 - IPC error. 1077 * @throws { BusinessError } 13900002 - No such file or directory. 1078 * @throws { BusinessError } 14000002 - Invalid URI. 1079 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1080 * @since arkts{ '1.1':'11','1.2':'20'} 1081 * @arkts 1.1&1.2 1082 */ 1083 stop(uri: string, callback: AsyncCallback<void>): void; 1084 /** 1085 * Batch stop the cloud file caches download task. 1086 * 1087 * @param { number } downloadId - The download ID of a batch of file cache. 1088 * @param { boolean } [needClean] - whether to delete the file that already downloaded. 1089 * @returns { Promise<void> } - Return Promise. 1090 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1091 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1092 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1093 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1094 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1095 * <br>1.Failed to access the database or execute the SQL statement. 1096 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1097 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1098 * @since 20 1099 * @arkts 1.1&1.2 1100 */ 1101 stopBatch(downloadId: number, needClean?: boolean): Promise<void>; 1102 /** 1103 * Clean the local file cache. 1104 * 1105 * @permission ohos.permission.CLOUDFILE_SYNC 1106 * @param { string } uri - uri of file. 1107 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 1108 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1109 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1110 * <br>2.Incorrect parameter types. 1111 * @throws { BusinessError } 13600001 - IPC error. 1112 * @throws { BusinessError } 13900002 - No such file or directory. 1113 * @throws { BusinessError } 14000002 - Invalid URI. 1114 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1115 * @systemapi 1116 * @since arkts{ '1.1':'11','1.2':'20'} 1117 * @arkts 1.1&1.2 1118 */ 1119 cleanCache(uri: string): void; 1120 /** 1121 * Clean local content of the file that has been synced to the Cloud 1122 * 1123 * @param { string } uri - uri of file. 1124 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1125 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1126 * @throws { BusinessError } 13900002 - No such file or directory. 1127 * @throws { BusinessError } 13900010 - Try again. 1128 * @throws { BusinessError } 13900012 - Permission denied by the file system 1129 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1130 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1131 * @throws { BusinessError } 14000002 - Invalid URI. 1132 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1133 * <br>1.Failed to access the database or execute the SQL statement. 1134 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1135 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1136 * @since 20 1137 */ 1138 cleanFileCache(uri: string): void; 1139 } 1140 1141 /** 1142 * Describes the external sync state of file. 1143 * @enum { number } 1144 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1145 * @since 20 1146 */ 1147 enum FileState { 1148 /** 1149 * Indicates the initial state after a file is downloaded from the cloud to the local host. 1150 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1151 * @since 20 1152 */ 1153 INITIAL_AFTER_DOWNLOAD = 0, 1154 /** 1155 * Indicates that the file is uploading now. 1156 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1157 * @since 20 1158 */ 1159 UPLOADING = 1, 1160 /** 1161 * Indicates that the file sync task stopped. 1162 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1163 * @since 20 1164 */ 1165 STOPPED = 2, 1166 /** 1167 * Indicates that the file is waiting for upload. 1168 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1169 * @since 20 1170 */ 1171 TO_BE_UPLOADED = 3, 1172 /** 1173 * Indicates that the file has been already uploaded successfully. 1174 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1175 * @since 20 1176 */ 1177 UPLOAD_SUCCESS = 4, 1178 /** 1179 * Indicates that the file upload failure 1180 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1181 * @since 20 1182 */ 1183 UPLOAD_FAILURE = 5 1184 } 1185 /** 1186 * Describes the sync state of file. 1187 * 1188 * @enum { number } 1189 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1190 * @systemapi 1191 * @since arkts{ '1.1':'11','1.2':'20'} 1192 * @arkts 1.1&1.2 1193 */ 1194 enum FileSyncState { 1195 /** 1196 * Indicates that the file cache is uploading now. 1197 * 1198 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1199 * @systemapi 1200 * @since arkts{ '1.1':'11','1.2':'20'} 1201 * @arkts 1.1&1.2 1202 */ 1203 UPLOADING = 0, 1204 /** 1205 * Indicates that the file cache is downloading now. 1206 * 1207 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1208 * @systemapi 1209 * @since arkts{ '1.1':'11','1.2':'20'} 1210 * @arkts 1.1&1.2 1211 */ 1212 DOWNLOADING = 1, 1213 /** 1214 * Indicates that the file cache sync task finished. 1215 * 1216 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1217 * @systemapi 1218 * @since arkts{ '1.1':'11','1.2':'20'} 1219 * @arkts 1.1&1.2 1220 */ 1221 COMPLETED = 2, 1222 /** 1223 * Indicates that the file cache sync task stopped. 1224 * 1225 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1226 * @systemapi 1227 * @since arkts{ '1.1':'11','1.2':'20'} 1228 * @arkts 1.1&1.2 1229 */ 1230 STOPPED = 3, 1231 /** 1232 * Indicates that the file is waiting for upload. 1233 * 1234 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1235 * @systemapi 1236 * @since arkts{ '1.1':'12','1.2':'20'} 1237 * @arkts 1.1&1.2 1238 */ 1239 TO_BE_UPLOADED = 4, 1240 /** 1241 * Indicates that the file has been already uploaded successfully. 1242 * 1243 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1244 * @systemapi 1245 * @since arkts{ '1.1':'12','1.2':'20'} 1246 * @arkts 1.1&1.2 1247 */ 1248 UPLOAD_SUCCESS = 5, 1249 /** 1250 * Indicates that the file upload failure. 1251 * 1252 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1253 * @systemapi 1254 * @since arkts{ '1.1':'12','1.2':'20'} 1255 * @arkts 1.1&1.2 1256 */ 1257 UPLOAD_FAILURE = 6, 1258 } 1259 1260 /** 1261 * Get the sync state of file. 1262 * 1263 * @permission ohos.permission.CLOUDFILE_SYNC 1264 * @param { Array<string> } uri - uri of files. 1265 * @returns { Promise<Array<FileSyncState>> } - Return the sync state of given files. 1266 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 1267 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1268 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1269 * <br>2.Incorrect parameter types. 1270 * @throws { BusinessError } 13600001 - IPC error. 1271 * @throws { BusinessError } 13900002 - No such file or directory. 1272 * @throws { BusinessError } 14000002 - Invalid URI. 1273 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1274 * @systemapi 1275 * @since arkts{ '1.1':'11','1.2':'20'} 1276 * @arkts 1.1&1.2 1277 */ 1278 function getFileSyncState(uri: Array<string>): Promise<Array<FileSyncState>>; 1279 /** 1280 * Get the sync state of the specified file. 1281 * 1282 * @param { string } uri - uri of file. 1283 * @returns { FileState } - return the sync state of the specified file. 1284 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1285 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1286 * @throws { BusinessError } 13900002 - No such file or directory. 1287 * @throws { BusinessError } 13900004 - Interrupted system call 1288 * @throws { BusinessError } 13900010 - Try again 1289 * @throws { BusinessError } 13900012 - Permission denied by the file system 1290 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1291 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1292 * @throws { BusinessError } 13900031 - Function not implemented 1293 * @throws { BusinessError } 14000002 - Invalid URI. 1294 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1295 * <br>1.Failed to access the database or execute the SQL statement. 1296 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1297 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1298 * @since 20 1299 */ 1300 function getCoreFileSyncState(uri: string): FileState; 1301 /** 1302 * Get the sync state of file. 1303 * 1304 * @permission ohos.permission.CLOUDFILE_SYNC 1305 * @param { Array<string> } uri - uri of file. 1306 * @param { AsyncCallback<Array<FileSyncState>> } callback - The callback is used to return the sync state of given files. 1307 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 1308 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1309 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1310 * <br>2.Incorrect parameter types. 1311 * @throws { BusinessError } 13600001 - IPC error. 1312 * @throws { BusinessError } 13900002 - No such file or directory. 1313 * @throws { BusinessError } 14000002 - Invalid URI. 1314 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1315 * @systemapi 1316 * @since arkts{ '1.1':'11','1.2':'20'} 1317 * @arkts 1.1&1.2 1318 */ 1319 function getFileSyncState(uri: Array<string>, callback: AsyncCallback<Array<FileSyncState>>): void; 1320 /** 1321 * Get the sync state of file. 1322 * 1323 * @param { string } uri - uri of file. 1324 * @returns { FileSyncState } - return the sync state of given files. 1325 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1326 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1327 * <br>2.Incorrect parameter types. 1328 * @throws { BusinessError } 13900002 - No such file or directory. 1329 * @throws { BusinessError } 13900004 - Interrupted system call 1330 * @throws { BusinessError } 13900010 - Try again 1331 * @throws { BusinessError } 13900012 - Permission denied by the file system 1332 * @throws { BusinessError } 13900031 - Function not implemented 1333 * @throws { BusinessError } 13900042 - Unknown error 1334 * @throws { BusinessError } 14000002 - Invalid URI. 1335 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1336 * @systemapi 1337 * @since arkts{ '1.1':'12','1.2':'20'} 1338 * @arkts 1.1&1.2 1339 */ 1340 function getFileSyncState(uri: string): FileSyncState; 1341 /** 1342 * Register change notify for the specified uri. 1343 * 1344 * @param { string } uri - uri of file. 1345 * @param { boolean } recursion - Whether to monitor the child files. 1346 * @param { Callback<ChangeData> } callback - Returns the changed data. 1347 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1348 * <br>2.Incorrect parameter types. 1349 * @throws { BusinessError } 13900001 - Operation not permitted 1350 * @throws { BusinessError } 13900002 - No such file or directory. 1351 * @throws { BusinessError } 13900012 - Permission denied 1352 * @throws { BusinessError } 14000002 - Invalid URI. 1353 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1354 * @since arkts{ '1.1':'12','1.2':'20'} 1355 * @arkts 1.1&1.2 1356 */ 1357 function registerChange(uri: string, recursion: boolean, callback: Callback<ChangeData>): void; 1358 /** 1359 * Unregister change notify fir the specified uri. 1360 * 1361 * @param { string } uri - uri of file. 1362 * @throws { BusinessError } 401 - The input parameter is invalid.Possible causes:1.Mandatory parameters are left unspecified; 1363 * <br>2.Incorrect parameter types. 1364 * @throws { BusinessError } 13900001 - Operation not permitted 1365 * @throws { BusinessError } 13900002 - No such file or directory. 1366 * @throws { BusinessError } 13900012 - Permission denied 1367 * @throws { BusinessError } 14000002 - Invalid URI. 1368 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1369 * @since arkts{ '1.1':'12','1.2':'20'} 1370 * @arkts 1.1&1.2 1371 */ 1372 function unregisterChange(uri: string): void; 1373 1374 /** 1375 * Enumeration types of data change. 1376 * 1377 * @enum { number } NotifyType 1378 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1379 * @since arkts{ '1.1':'12','1.2':'20'} 1380 * @arkts 1.1&1.2 1381 */ 1382 enum NotifyType { 1383 /** 1384 * File has been newly created 1385 * 1386 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1387 * @since arkts{ '1.1':'12','1.2':'20'} 1388 * @arkts 1.1&1.2 1389 */ 1390 NOTIFY_ADDED = 0, 1391 /** 1392 * File has been modified. 1393 * 1394 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1395 * @since arkts{ '1.1':'12','1.2':'20'} 1396 * @arkts 1.1&1.2 1397 */ 1398 NOTIFY_MODIFIED = 1, 1399 /** 1400 * File has been deleted. 1401 * 1402 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1403 * @since arkts{ '1.1':'12','1.2':'20'} 1404 * @arkts 1.1&1.2 1405 */ 1406 NOTIFY_DELETED = 2, 1407 /** 1408 * File has been renamed or moved. 1409 * 1410 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1411 * @since arkts{ '1.1':'12','1.2':'20'} 1412 * @arkts 1.1&1.2 1413 */ 1414 NOTIFY_RENAMED = 3, 1415 } 1416 1417 /** 1418 * Defines the change data 1419 * 1420 * @interface ChangeData 1421 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1422 * @since arkts{ '1.1':'12','1.2':'20'} 1423 * @arkts 1.1&1.2 1424 */ 1425 interface ChangeData { 1426 /** 1427 * The notify type of the change. 1428 * 1429 * @type {NotifyType} 1430 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1431 * @since arkts{ '1.1':'12','1.2':'20'} 1432 * @arkts 1.1&1.2 1433 */ 1434 type: NotifyType; 1435 /** 1436 * Indicates whether the changed uri is directory. 1437 * 1438 * @type {Array<boolean>} 1439 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1440 * @since arkts{ '1.1':'12','1.2':'20'} 1441 * @arkts 1.1&1.2 1442 */ 1443 isDirectory: Array<boolean>; 1444 /** 1445 * The changed uris. 1446 * 1447 * @type {Array<string>} 1448 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1449 * @since arkts{ '1.1':'12','1.2':'20'} 1450 * @arkts 1.1&1.2 1451 */ 1452 uris: Array<string>; 1453 } 1454 1455 /** 1456 * Optimize storage space 1457 * 1458 * @permission ohos.permission.CLOUDFILE_SYNC 1459 * @returns { Promise<void> } - Return Promise. 1460 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 1461 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1462 * <br>2.Incorrect parameter types. 1463 * @throws { BusinessError } 13600001 - IPC error. 1464 * @throws { BusinessError } 13900042 - Unknown error. 1465 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1466 * @systemapi 1467 * @since arkts{ '1.1':'17','1.2':'20'} 1468 * @arkts 1.1&1.2 1469 */ 1470 function optimizeStorage(): Promise<void>; 1471 1472 /** 1473 * Start optimize storage space task. 1474 * 1475 * @permission ohos.permission.CLOUDFILE_SYNC 1476 * @param { OptimizeSpaceParam } optimizePara - Setting parameters with a `OptimizeSpaceParam` argument. 1477 * @param { Callback<OptimizeSpaceProgress> } callback - callback function with a `OptimizeSpaceProgress` argument. 1478 * @returns { Promise<void> } - Return Promise. 1479 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 1480 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1481 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1482 * @throws { BusinessError } 13600001 - IPC error. 1483 * @throws { BusinessError } 22400005 - Inner error. 1484 * @throws { BusinessError } 22400006 - The same task is already in progress. 1485 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1486 * @systemapi 1487 * @since arkts{ '1.1':'17','1.2':'20'} 1488 * @arkts 1.1&1.2 1489 */ 1490 function startOptimizeSpace(optimizePara: OptimizeSpaceParam, callback?: Callback<OptimizeSpaceProgress>): Promise<void>; 1491 1492 /** 1493 * Stop optimize storage space task. 1494 * 1495 * @permission ohos.permission.CLOUDFILE_SYNC 1496 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 1497 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1498 * @throws { BusinessError } 13600001 - IPC error. 1499 * @throws { BusinessError } 22400005 - Inner error. 1500 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1501 * @systemapi 1502 * @since arkts{ '1.1':'17','1.2':'20'} 1503 * @arkts 1.1&1.2 1504 */ 1505 function stopOptimizeSpace(): void; 1506 1507 /** 1508 * Describes the state type of optimize space task. 1509 * @enum { number } OptimizeState 1510 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1511 * @systemapi 1512 * @since arkts{ '1.1':'17','1.2':'20'} 1513 * @arkts 1.1&1.2 1514 */ 1515 enum OptimizeState { 1516 1517 /** 1518 * Indicates that the optimize space task in process now. 1519 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1520 * @systemapi 1521 * @since arkts{ '1.1':'17','1.2':'20'} 1522 * @arkts 1.1&1.2 1523 */ 1524 RUNNING = 0, 1525 1526 /** 1527 * Indicates that the optimize space task finished successfully. 1528 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1529 * @systemapi 1530 * @since arkts{ '1.1':'17','1.2':'20'} 1531 * @arkts 1.1&1.2 1532 */ 1533 COMPLETED = 1, 1534 1535 /** 1536 * Indicates that the optimize space task failed. 1537 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1538 * @systemapi 1539 * @since arkts{ '1.1':'17','1.2':'20'} 1540 * @arkts 1.1&1.2 1541 */ 1542 FAILED = 2, 1543 1544 /** 1545 * Indicates that the optimize space task stopped. 1546 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1547 * @systemapi 1548 * @since arkts{ '1.1':'17','1.2':'20'} 1549 * @arkts 1.1&1.2 1550 */ 1551 STOPPED = 3 1552 } 1553 1554 /** 1555 * Defines the OptimizeSpaceProgress data structure. 1556 * @typedef OptimizeSpaceProgress 1557 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1558 * @systemapi 1559 * @since arkts{ '1.1':'17','1.2':'20'} 1560 * @arkts 1.1&1.2 1561 */ 1562 interface OptimizeSpaceProgress { 1563 1564 /** 1565 * The current optimize space task state. 1566 * @permission ohos.permission.CLOUDFILE_SYNC 1567 * @type { OptimizeState } 1568 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1569 * @systemapi 1570 * @since arkts{ '1.1':'17','1.2':'20'} 1571 * @arkts 1.1&1.2 1572 */ 1573 state: OptimizeState; 1574 1575 /** 1576 * The percentage of clearing files. 1577 * @permission ohos.permission.CLOUDFILE_SYNC 1578 * @type { number } 1579 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1580 * @systemapi 1581 * @since arkts{ '1.1':'17','1.2':'20'} 1582 * @arkts 1.1&1.2 1583 */ 1584 progress: number; 1585 } 1586 1587 /** 1588 * Defines the OptimizeSpaceParam data structure. 1589 * @typedef OptimizeSpaceParam 1590 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1591 * @systemapi 1592 * @since arkts{ '1.1':'17','1.2':'20'} 1593 * @arkts 1.1&1.2 1594 */ 1595 interface OptimizeSpaceParam { 1596 1597 /** 1598 * The total size(Unit:byte) of clean space. 1599 * @permission ohos.permission.CLOUDFILE_SYNC 1600 * @type { number } 1601 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1602 * @systemapi 1603 * @since arkts{ '1.1':'17','1.2':'20'} 1604 * @arkts 1.1&1.2 1605 */ 1606 totalSize: number; 1607 1608 /** 1609 * Clean files that are not accessed agingDays(unit:day) ago. 1610 * @permission ohos.permission.CLOUDFILE_SYNC 1611 * @type { number } 1612 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1613 * @systemapi 1614 * @since arkts{ '1.1':'17','1.2':'20'} 1615 * @arkts 1.1&1.2 1616 */ 1617 agingDays: number; 1618 } 1619 1620 /** 1621 * Defines the HistoryVersion data structure. 1622 * @typedef HistoryVersion 1623 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1624 * @since 20 1625 */ 1626 interface HistoryVersion { 1627 /** 1628 * The time when the content of this version file is edited. 1629 * @type { number } 1630 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1631 * @since 20 1632 */ 1633 editedTime: number; 1634 /** 1635 * The size of this history version file. 1636 * @type { number } 1637 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1638 * @since 20 1639 */ 1640 fileSize: number; 1641 /** 1642 * The version ID of this version. 1643 * @type { string } 1644 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1645 * @since 20 1646 */ 1647 versionId: string; 1648 /** 1649 * The original file name used to create this version. 1650 * @type { string } 1651 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1652 * @since 20 1653 */ 1654 originalFileName: string; 1655 /** 1656 * The Sha256 check value of this version file. 1657 * @type { string } 1658 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1659 * @since 20 1660 */ 1661 sha256: string; 1662 /** 1663 * Indicates whether this version automatically resolves the conflict. 1664 * @type { boolean } 1665 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1666 * @since 20 1667 */ 1668 autoResolved: boolean; 1669 } 1670 1671 /** 1672 * Defines the VersionDownloadProgress data structure. 1673 * @typedef VersionDownloadProgress 1674 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1675 * @since 20 1676 */ 1677 interface VersionDownloadProgress { 1678 /** 1679 * The current download task state. 1680 * @type { State } 1681 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1682 * @since 20 1683 */ 1684 state: State; 1685 /** 1686 * The percentage of downloaded files. 1687 * @type { number } 1688 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1689 * @since 20 1690 */ 1691 progress: number; 1692 /** 1693 * The error type of download. 1694 * @type { DownloadErrorType } 1695 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1696 * @since 20 1697 */ 1698 errType: DownloadErrorType; 1699 } 1700 1701 /** 1702 * FileVersion object. 1703 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1704 * @since 20 1705 */ 1706 class FileVersion { 1707 /** 1708 * A constructor used to create a FileVersion object. 1709 * 1710 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1711 * <br>1.Failed to access the database or execute the SQL statement. 1712 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1713 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1714 * @since 20 1715 */ 1716 constructor(); 1717 /** 1718 * Get the specified number of most recent historical versions of the file specified by the URI. 1719 * 1720 * @param { string } uri - uri of file. 1721 * @param { number } versionNumLimit - Maximum number of historical versions you want to obtained. 1722 * @returns { Promise<Array<HistoryVersion>> } - Return the most recent history version list of the specified file. 1723 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1724 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1725 * @throws { BusinessError } 13900002 - No such file or directory. 1726 * @throws { BusinessError } 13900010 - Try again. 1727 * @throws { BusinessError } 13900012 - Permission denied by the file system. 1728 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1729 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1730 * @throws { BusinessError } 14000002 - Invalid URI. 1731 * @throws { BusinessError } 22400002 - Network unavailable. 1732 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1733 * <br>1.Failed to access the database or execute the SQL statement. 1734 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1735 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1736 * @since 20 1737 */ 1738 getHistoryVersionList(uri: string, versionNumLimit: number): Promise<Array<HistoryVersion>>; 1739 /** 1740 * Download the content of the specified history version to the specified temporary directory. 1741 * 1742 * @param { string } uri - Uri of file. 1743 * @param { string } versionId - The version ID of the history version you want. 1744 * @param { Callback<VersionDownloadProgress> } callback - callback function with a `VersionDownloadProgress` argument. 1745 * @returns { Promise<string> } - Return the temporary directory to use for saving the content of the specified history version. 1746 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1747 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1748 * @throws { BusinessError } 13900002 - No such file or directory. 1749 * @throws { BusinessError } 13900010 - Try again. 1750 * @throws { BusinessError } 13900012 - Permission denied by the file system. 1751 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1752 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1753 * @throws { BusinessError } 14000002 - Invalid URI. 1754 * @throws { BusinessError } 22400002 - Network unavailable. 1755 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1756 * <br>1.Failed to access the database or execute the SQL statement. 1757 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1758 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1759 * @since 20 1760 */ 1761 downloadHistoryVersion(uri: string, versionId: string, callback: Callback<VersionDownloadProgress>): Promise<string>; 1762 /** 1763 * Replace the content of the specified file with the content of the specified history version. 1764 * 1765 * @param { string } originalUri - The uri of the file whose content you want to replace. 1766 * @param { string } versionUri - The uri of the downloaded history version used to replace the original file. 1767 * @returns { Promise<void> } - Return Promise. 1768 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1769 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1770 * @throws { BusinessError } 13900002 - No such file or directory. 1771 * @throws { BusinessError } 13900005 - I/O error. 1772 * @throws { BusinessError } 13900008 - Bad file descriptor. 1773 * @throws { BusinessError } 13900010 - Try again. 1774 * @throws { BusinessError } 13900012 - Permission denied by the file system. 1775 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1776 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1777 * @throws { BusinessError } 14000002 - Invalid URI. Possible causes: 1.originalUri invalid; 2.versionUri invalid. 1778 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1779 * <br>1.Failed to access the database or execute the SQL statement. 1780 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1781 * @throws { BusinessError } 22400007 - The version file specified to replace the original file does not exist. 1782 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1783 * @since 20 1784 */ 1785 replaceFileWithHistoryVersion(originalUri: string, versionUri: string): Promise<void>; 1786 /** 1787 * Check whether the current file content is in conflict with other versions. 1788 * 1789 * @param { string } uri - Uri of file. 1790 * @returns { Promise<boolean> } - Return a Boolean value indicating whether the current file content is in conflict with other versions. 1791 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1792 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1793 * @throws { BusinessError } 13900002 - No such file or directory. 1794 * @throws { BusinessError } 13900010 - Try again. 1795 * @throws { BusinessError } 13900012 - Permission denied by the file system. 1796 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1797 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1798 * @throws { BusinessError } 14000002 - Invalid URI. 1799 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1800 * <br>1.Failed to access the database or execute the SQL statement. 1801 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1802 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1803 * @since 20 1804 */ 1805 isFileConflict(uri: string): Promise<boolean>; 1806 /** 1807 * Clean the current file conflict flag after the conflict is resolved. 1808 * 1809 * @param { string } uri - Uri of file. 1810 * @returns { Promise<void> } - Return Promise. 1811 * @throws { BusinessError } 13600001 - IPC error. Possible causes: 1812 * <br>1.IPC failed or timed out. 2.Failed to load the service. 1813 * @throws { BusinessError } 13900002 - No such file or directory. 1814 * @throws { BusinessError } 13900010 - Try again. 1815 * @throws { BusinessError } 13900012 - Permission denied by the file system. 1816 * @throws { BusinessError } 13900020 - Invalid argument. Possible causes: 1817 * <br>1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1818 * @throws { BusinessError } 14000002 - Invalid URI. 1819 * @throws { BusinessError } 22400005 - Inner error. Possible causes: 1820 * <br>1.Failed to access the database or execute the SQL statement. 1821 * <br>2.System error, such as a null pointer, insufficient memory or a JS engine exception. 1822 * @syscap SystemCapability.FileManagement.DistributedFileService.CloudSync.Core 1823 * @since 20 1824 */ 1825 clearFileConflict(uri: string): Promise<void>; 1826 } 1827} 1828 1829export default cloudSync; 1830