1/* 2 * Copyright (c) 2022 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 BasicServicesKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import { Callback } from './@ohos.base'; 23import BaseContext from './application/BaseContext'; 24 25/** 26 * upload and download 27 * 28 * @namespace request 29 * @since 6 30 */ 31/** 32 * upload and download 33 * 34 * @namespace request 35 * @syscap SystemCapability.Request.FileTransferAgent 36 * @crossplatform 37 * @since 10 38 */ 39/** 40 * upload and download 41 * 42 * @namespace request 43 * @syscap SystemCapability.Request.FileTransferAgent 44 * @crossplatform 45 * @atomicservice 46 * @since 11 47 */ 48declare namespace request { 49 /** 50 * Error code 201 - the permissions check fails. 51 * 52 * @constant 53 * @syscap SystemCapability.MiscServices.Download 54 * @since 9 55 */ 56 /** 57 * Error code 201 - the permissions check fails. 58 * 59 * @constant 60 * @syscap SystemCapability.MiscServices.Download 61 * @crossplatform 62 * @since 10 63 */ 64 const EXCEPTION_PERMISSION: number; 65 /** 66 * Error code 401 - the parameters check fails. 67 * 68 * @constant 69 * @syscap SystemCapability.MiscServices.Download 70 * @since 9 71 */ 72 /** 73 * Error code 401 - the parameters check fails. 74 * 75 * @constant 76 * @syscap SystemCapability.MiscServices.Download 77 * @crossplatform 78 * @since 10 79 */ 80 const EXCEPTION_PARAMCHECK: number; 81 /** 82 * Error code 801 - call unsupported api. 83 * 84 * @constant 85 * @syscap SystemCapability.MiscServices.Download 86 * @since 9 87 */ 88 /** 89 * Error code 801 - call unsupported api. 90 * 91 * @constant 92 * @syscap SystemCapability.MiscServices.Download 93 * @crossplatform 94 * @since 10 95 */ 96 const EXCEPTION_UNSUPPORTED: number; 97 /** 98 * Error code 13400001 - file operation error. 99 * 100 * @constant 101 * @syscap SystemCapability.MiscServices.Download 102 * @since 9 103 */ 104 /** 105 * Error code 13400001 - file operation error. 106 * 107 * @constant 108 * @syscap SystemCapability.MiscServices.Download 109 * @crossplatform 110 * @since 10 111 */ 112 const EXCEPTION_FILEIO: number; 113 /** 114 * Error code 13400002 - bad file path. 115 * 116 * @constant 117 * @syscap SystemCapability.MiscServices.Download 118 * @since 9 119 */ 120 /** 121 * Error code 13400002 - bad file path. 122 * 123 * @constant 124 * @syscap SystemCapability.MiscServices.Download 125 * @crossplatform 126 * @since 10 127 */ 128 const EXCEPTION_FILEPATH: number; 129 /** 130 * Error code 13400003 - task service ability error. 131 * 132 * @constant 133 * @syscap SystemCapability.MiscServices.Download 134 * @since 9 135 */ 136 /** 137 * Error code 13400003 - task service ability error. 138 * 139 * @constant 140 * @syscap SystemCapability.MiscServices.Download 141 * @crossplatform 142 * @since 10 143 */ 144 const EXCEPTION_SERVICE: number; 145 /** 146 * Error code 13499999 - others error. 147 * 148 * @constant 149 * @syscap SystemCapability.MiscServices.Download 150 * @since 9 151 */ 152 /** 153 * Error code 13499999 - others error. 154 * 155 * @constant 156 * @syscap SystemCapability.MiscServices.Download 157 * @crossplatform 158 * @since 10 159 */ 160 const EXCEPTION_OTHERS: number; 161 162 /** 163 * Code 0x00000001 - Bit flag indicating download is allowed when using the cellular network. 164 * 165 * @constant 166 * @syscap SystemCapability.MiscServices.Download 167 * @since 6 168 */ 169 /** 170 * Code 0x00000001 - Bit flag indicating download is allowed when using the cellular network. 171 * 172 * @constant 173 * @syscap SystemCapability.MiscServices.Download 174 * @crossplatform 175 * @since 10 176 */ 177 const NETWORK_MOBILE: number; 178 179 /** 180 * Code 0x00010000 - Bit flag indicating download is allowed when using the WLAN. 181 * 182 * @constant 183 * @syscap SystemCapability.MiscServices.Download 184 * @since 6 185 */ 186 /** 187 * Code 0x00010000 - Bit flag indicating download is allowed when using the WLAN. 188 * 189 * @constant 190 * @syscap SystemCapability.MiscServices.Download 191 * @crossplatform 192 * @since 10 193 */ 194 const NETWORK_WIFI: number; 195 196 /** 197 * Error code 0 - Indicates that the download cannot be resumed for network reasons. 198 * 199 * @constant 200 * @syscap SystemCapability.MiscServices.Download 201 * @since 7 202 */ 203 /** 204 * Error code 0 - Indicates that the download cannot be resumed for network reasons. 205 * 206 * @constant 207 * @syscap SystemCapability.MiscServices.Download 208 * @crossplatform 209 * @since 10 210 */ 211 const ERROR_CANNOT_RESUME: number; 212 213 /** 214 * Error code 1 - Indicates that no storage device, such as an SD card, is found. 215 * 216 * @constant 217 * @syscap SystemCapability.MiscServices.Download 218 * @since 7 219 */ 220 /** 221 * Error code 1 - Indicates that no storage device, such as an SD card, is found. 222 * 223 * @constant 224 * @syscap SystemCapability.MiscServices.Download 225 * @crossplatform 226 * @since 10 227 */ 228 const ERROR_DEVICE_NOT_FOUND: number; 229 230 /** 231 * Error code 2 - Indicates that files to be downloaded already exist, and that the download session cannot overwrite the existing files. 232 * 233 * @constant 234 * @syscap SystemCapability.MiscServices.Download 235 * @since 7 236 */ 237 /** 238 * Error code 2 - Indicates that files to be downloaded already exist, and that the download session cannot overwrite the existing files. 239 * 240 * @constant 241 * @syscap SystemCapability.MiscServices.Download 242 * @crossplatform 243 * @since 10 244 */ 245 const ERROR_FILE_ALREADY_EXISTS: number; 246 247 /** 248 * Error code 3 - Indicates that a file operation fails. 249 * 250 * @constant 251 * @syscap SystemCapability.MiscServices.Download 252 * @since 7 253 */ 254 /** 255 * Error code 3 - Indicates that a file operation fails. 256 * 257 * @constant 258 * @syscap SystemCapability.MiscServices.Download 259 * @crossplatform 260 * @since 10 261 */ 262 const ERROR_FILE_ERROR: number; 263 264 /** 265 * Error code 4 - Indicates that the HTTP transmission fails. 266 * 267 * @constant 268 * @syscap SystemCapability.MiscServices.Download 269 * @since 7 270 */ 271 /** 272 * Error code 4 - Indicates that the HTTP transmission fails. 273 * 274 * @constant 275 * @syscap SystemCapability.MiscServices.Download 276 * @crossplatform 277 * @since 10 278 */ 279 const ERROR_HTTP_DATA_ERROR: number; 280 281 /** 282 * Error code 5 - Indicates insufficient storage space. 283 * 284 * @constant 285 * @syscap SystemCapability.MiscServices.Download 286 * @since 7 287 */ 288 /** 289 * Error code 5 - Indicates insufficient storage space. 290 * 291 * @constant 292 * @syscap SystemCapability.MiscServices.Download 293 * @crossplatform 294 * @since 10 295 */ 296 const ERROR_INSUFFICIENT_SPACE: number; 297 298 /** 299 * Error code 6 - Indicates an error caused by too many network redirections. 300 * 301 * @constant 302 * @syscap SystemCapability.MiscServices.Download 303 * @since 7 304 */ 305 /** 306 * Error code 6 - Indicates an error caused by too many network redirections. 307 * 308 * @constant 309 * @syscap SystemCapability.MiscServices.Download 310 * @crossplatform 311 * @since 10 312 */ 313 const ERROR_TOO_MANY_REDIRECTS: number; 314 315 /** 316 * Error code 7 - Indicates an HTTP code that cannot be identified. 317 * 318 * @constant 319 * @syscap SystemCapability.MiscServices.Download 320 * @since 7 321 */ 322 /** 323 * Error code 7 - Indicates an HTTP code that cannot be identified. 324 * 325 * @constant 326 * @syscap SystemCapability.MiscServices.Download 327 * @crossplatform 328 * @since 10 329 */ 330 const ERROR_UNHANDLED_HTTP_CODE: number; 331 332 /** 333 * Error code 8 - Indicates an undefined error. 334 * 335 * @constant 336 * @syscap SystemCapability.MiscServices.Download 337 * @since 7 338 */ 339 /** 340 * Error code 8 - Indicates an undefined error. 341 * 342 * @constant 343 * @syscap SystemCapability.MiscServices.Download 344 * @crossplatform 345 * @since 10 346 */ 347 const ERROR_UNKNOWN: number; 348 349 /** 350 * Error code 9 - Indicates network offline. 351 * 352 * @constant 353 * @syscap SystemCapability.MiscServices.Download 354 * @since 9 355 */ 356 /** 357 * Error code 9 - Indicates network offline. 358 * 359 * @constant 360 * @syscap SystemCapability.MiscServices.Download 361 * @crossplatform 362 * @since 10 363 */ 364 const ERROR_OFFLINE: number; 365 366 /** 367 * Error code 10 - Indicates network type configuration error. 368 * 369 * @constant 370 * @syscap SystemCapability.MiscServices.Download 371 * @since 9 372 */ 373 /** 374 * Error code 10 - Indicates network type configuration error. 375 * 376 * @constant 377 * @syscap SystemCapability.MiscServices.Download 378 * @crossplatform 379 * @since 10 380 */ 381 const ERROR_UNSUPPORTED_NETWORK_TYPE: number; 382 383 /** 384 * Paused code 0 - Indicates that the download is paused and waiting for a WLAN connection, 385 * because the file size exceeds the maximum allowed for a session using the cellular network. 386 * 387 * @constant 388 * @syscap SystemCapability.MiscServices.Download 389 * @since 7 390 */ 391 /** 392 * Paused code 0 - Indicates that the download is paused and waiting for a WLAN connection, 393 * because the file size exceeds the maximum allowed for a session using the cellular network. 394 * 395 * @constant 396 * @syscap SystemCapability.MiscServices.Download 397 * @crossplatform 398 * @since 10 399 */ 400 const PAUSED_QUEUED_FOR_WIFI: number; 401 402 /** 403 * Paused code 1 - Indicates that the download is paused due to a network problem, for example, network disconnection. 404 * 405 * @constant 406 * @syscap SystemCapability.MiscServices.Download 407 * @since 7 408 */ 409 /** 410 * Paused code 1 - Indicates that the download is paused due to a network problem, for example, network disconnection. 411 * 412 * @constant 413 * @syscap SystemCapability.MiscServices.Download 414 * @crossplatform 415 * @since 10 416 */ 417 const PAUSED_WAITING_FOR_NETWORK: number; 418 419 /** 420 * Paused code 2 - Indicates that a network error occurs, and the download session will be retried. 421 * 422 * @constant 423 * @syscap SystemCapability.MiscServices.Download 424 * @since 7 425 */ 426 /** 427 * Paused code 2 - Indicates that a network error occurs, and the download session will be retried. 428 * 429 * @constant 430 * @syscap SystemCapability.MiscServices.Download 431 * @crossplatform 432 * @since 10 433 */ 434 const PAUSED_WAITING_TO_RETRY: number; 435 436 /** 437 * Paused code 3 - Indicates that the download is paused due to the user. 438 * 439 * @constant 440 * @syscap SystemCapability.MiscServices.Download 441 * @since 9 442 */ 443 /** 444 * Paused code 3 - Indicates that the download is paused due to the user. 445 * 446 * @constant 447 * @syscap SystemCapability.MiscServices.Download 448 * @crossplatform 449 * @since 10 450 */ 451 const PAUSED_BY_USER: number; 452 453 /** 454 * Paused code 4 - Indicates that the download is paused for some reasons. 455 * 456 * @constant 457 * @syscap SystemCapability.MiscServices.Download 458 * @since 7 459 */ 460 /** 461 * Paused code 4 - Indicates that the download is paused for some reasons. 462 * 463 * @constant 464 * @syscap SystemCapability.MiscServices.Download 465 * @crossplatform 466 * @since 10 467 */ 468 const PAUSED_UNKNOWN: number; 469 470 /** 471 * Session status code 0 - Indicates that the download session is completed. 472 * 473 * @constant 474 * @syscap SystemCapability.MiscServices.Download 475 * @since 7 476 */ 477 /** 478 * Session status code 0 - Indicates that the download session is completed. 479 * 480 * @constant 481 * @syscap SystemCapability.MiscServices.Download 482 * @crossplatform 483 * @since 10 484 */ 485 const SESSION_SUCCESSFUL: number; 486 487 /** 488 * Session status code 1 - Indicates that the download session is in progress. 489 * 490 * @constant 491 * @syscap SystemCapability.MiscServices.Download 492 * @since 7 493 */ 494 /** 495 * Session status code 1 - Indicates that the download session is in progress. 496 * 497 * @constant 498 * @syscap SystemCapability.MiscServices.Download 499 * @crossplatform 500 * @since 10 501 */ 502 const SESSION_RUNNING: number; 503 504 /** 505 * Session status code 2 - Indicates that the download session is being scheduled. 506 * 507 * @constant 508 * @syscap SystemCapability.MiscServices.Download 509 * @since 7 510 */ 511 /** 512 * Session status code 2 - Indicates that the download session is being scheduled. 513 * 514 * @constant 515 * @syscap SystemCapability.MiscServices.Download 516 * @crossplatform 517 * @since 10 518 */ 519 const SESSION_PENDING: number; 520 521 /** 522 * Session status code 3 - Indicates that the download session has been paused. 523 * 524 * @constant 525 * @syscap SystemCapability.MiscServices.Download 526 * @since 7 527 */ 528 /** 529 * Session status code 3 - Indicates that the download session has been paused. 530 * 531 * @constant 532 * @syscap SystemCapability.MiscServices.Download 533 * @crossplatform 534 * @since 10 535 */ 536 const SESSION_PAUSED: number; 537 538 /** 539 * Session status code 4 - Indicates that the download session has failed and will not be retried. 540 * 541 * @constant 542 * @syscap SystemCapability.MiscServices.Download 543 * @since 7 544 */ 545 /** 546 * Session status code 4 - Indicates that the download session has failed and will not be retried. 547 * 548 * @constant 549 * @syscap SystemCapability.MiscServices.Download 550 * @crossplatform 551 * @since 10 552 */ 553 const SESSION_FAILED: number; 554 555 /** 556 * Starts a download task. 557 * 558 * @permission ohos.permission.INTERNET 559 * @param { DownloadConfig } config Download config 560 * @param { AsyncCallback<DownloadTask> } callback Indicate the callback function to receive DownloadTask. 561 * @throws { BusinessError } 201 - the permissions check fails 562 * @syscap SystemCapability.MiscServices.Download 563 * @FAModelOnly 564 * @since 6 565 * @deprecated since 9 566 * @useinstead ohos.request.downloadFile 567 */ 568 function download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; 569 570 /** 571 * Starts a download task. 572 * 573 * @permission ohos.permission.INTERNET 574 * @param { BaseContext } context Indicates the application BaseContext. 575 * @param { DownloadConfig } config Download config 576 * @param { AsyncCallback<DownloadTask> } callback Indicate the callback function to receive DownloadTask. 577 * @throws { BusinessError } 201 - the permissions check fails 578 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 579 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 580 * @throws { BusinessError } 13400001 - file operation error 581 * @throws { BusinessError } 13400002 - bad file path 582 * @throws { BusinessError } 13400003 - task service ability error 583 * @syscap SystemCapability.MiscServices.Download 584 * @since 9 585 */ 586 /** 587 * Starts a download task. 588 * 589 * @permission ohos.permission.INTERNET 590 * @param { BaseContext } context Indicates the application BaseContext. 591 * @param { DownloadConfig } config Download config 592 * @param { AsyncCallback<DownloadTask> } callback Indicate the callback function to receive DownloadTask. 593 * @throws { BusinessError } 201 - the permissions check fails 594 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 595 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 596 * @throws { BusinessError } 13400001 - file operation error 597 * @throws { BusinessError } 13400002 - bad file path 598 * @throws { BusinessError } 13400003 - task service ability error 599 * @syscap SystemCapability.MiscServices.Download 600 * @crossplatform 601 * @since 10 602 */ 603 function downloadFile(context: BaseContext, config: DownloadConfig, callback: AsyncCallback<DownloadTask>): void; 604 605 /** 606 * Starts a download task. 607 * 608 * @permission ohos.permission.INTERNET 609 * @param { DownloadConfig } config Download config 610 * @returns { Promise<DownloadTask> } the promise returned by the function. 611 * @throws { BusinessError } 201 - the permissions check fails 612 * @syscap SystemCapability.MiscServices.Download 613 * @FAModelOnly 614 * @since 6 615 * @deprecated since 9 616 * @useinstead ohos.request.downloadFile 617 */ 618 function download(config: DownloadConfig): Promise<DownloadTask>; 619 620 /** 621 * Starts a download task. 622 * 623 * @permission ohos.permission.INTERNET 624 * @param { BaseContext } context Indicates the application BaseContext. 625 * @param { DownloadConfig } config Download config 626 * @returns { Promise<DownloadTask> } the promise returned by the function. 627 * @throws { BusinessError } 201 - the permissions check fails 628 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 629 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 630 * @throws { BusinessError } 13400001 - file operation error 631 * @throws { BusinessError } 13400002 - bad file path 632 * @throws { BusinessError } 13400003 - task service ability error 633 * @syscap SystemCapability.MiscServices.Download 634 * @since 9 635 */ 636 /** 637 * Starts a download task. 638 * 639 * @permission ohos.permission.INTERNET 640 * @param { BaseContext } context Indicates the application BaseContext. 641 * @param { DownloadConfig } config Download config 642 * @returns { Promise<DownloadTask> } the promise returned by the function. 643 * @throws { BusinessError } 201 - the permissions check fails 644 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 645 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 646 * @throws { BusinessError } 13400001 - file operation error 647 * @throws { BusinessError } 13400002 - bad file path 648 * @throws { BusinessError } 13400003 - task service ability error 649 * @syscap SystemCapability.MiscServices.Download 650 * @crossplatform 651 * @since 10 652 */ 653 function downloadFile(context: BaseContext, config: DownloadConfig): Promise<DownloadTask>; 654 655 /** 656 * Starts an upload task. 657 * 658 * @permission ohos.permission.INTERNET 659 * @param { UploadConfig } config Upload config 660 * @param { AsyncCallback<UploadTask> } callback Indicate the callback function to receive UploadTask. 661 * @throws { BusinessError } 201 - the permissions check fails 662 * @syscap SystemCapability.MiscServices.Upload 663 * @FAModelOnly 664 * @since 6 665 * @deprecated since 9 666 * @useinstead ohos.request.uploadFile 667 */ 668 function upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void; 669 670 /** 671 * Starts an upload task. 672 * 673 * @permission ohos.permission.INTERNET 674 * @param { BaseContext } context Indicates the application BaseContext. 675 * @param { UploadConfig } config Upload config 676 * @param { AsyncCallback<UploadTask> } callback Indicate the callback function to receive UploadTask. 677 * @throws { BusinessError } 201 - the permissions check fails 678 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 679 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 680 * @throws { BusinessError } 13400002 - bad file path 681 * @syscap SystemCapability.MiscServices.Upload 682 * @since 9 683 */ 684 /** 685 * Starts an upload task. 686 * 687 * @permission ohos.permission.INTERNET 688 * @param { BaseContext } context Indicates the application BaseContext. 689 * @param { UploadConfig } config Upload config 690 * @param { AsyncCallback<UploadTask> } callback Indicate the callback function to receive UploadTask. 691 * @throws { BusinessError } 201 - the permissions check fails 692 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 693 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 694 * @throws { BusinessError } 13400002 - bad file path 695 * @syscap SystemCapability.MiscServices.Upload 696 * @crossplatform 697 * @since 10 698 */ 699 function uploadFile(context: BaseContext, config: UploadConfig, callback: AsyncCallback<UploadTask>): void; 700 701 /** 702 * Starts an upload task. 703 * 704 * @permission ohos.permission.INTERNET 705 * @param { UploadConfig } config Upload config 706 * @returns { Promise<UploadTask> } the promise returned by the function. 707 * @throws { BusinessError } 201 - the permissions check fails 708 * @syscap SystemCapability.MiscServices.Upload 709 * @FAModelOnly 710 * @since 6 711 * @deprecated since 9 712 * @useinstead ohos.request.uploadFile 713 */ 714 function upload(config: UploadConfig): Promise<UploadTask>; 715 716 /** 717 * Starts an upload task. 718 * 719 * @permission ohos.permission.INTERNET 720 * @param { BaseContext } context Indicates the application BaseContext. 721 * @param { UploadConfig } config Upload config 722 * @returns { Promise<UploadTask> } the promise returned by the function. 723 * @throws { BusinessError } 201 - the permissions check fails 724 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 725 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 726 * @throws { BusinessError } 13400002 - bad file path 727 * @syscap SystemCapability.MiscServices.Upload 728 * @since 9 729 */ 730 /** 731 * Starts an upload task. 732 * 733 * @permission ohos.permission.INTERNET 734 * @param { BaseContext } context Indicates the application BaseContext. 735 * @param { UploadConfig } config Upload config 736 * @returns { Promise<UploadTask> } the promise returned by the function. 737 * @throws { BusinessError } 201 - the permissions check fails 738 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 739 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 740 * @throws { BusinessError } 13400002 - bad file path 741 * @syscap SystemCapability.MiscServices.Upload 742 * @crossplatform 743 * @since 10 744 */ 745 function uploadFile(context: BaseContext, config: UploadConfig): Promise<UploadTask>; 746 747 /** 748 * DownloadConfig data Structure 749 * 750 * @interface DownloadConfig 751 * @syscap SystemCapability.MiscServices.Download 752 * @since 6 753 * @name DownloadConfig 754 */ 755 /** 756 * DownloadConfig data Structure 757 * 758 * @typedef DownloadConfig 759 * @syscap SystemCapability.MiscServices.Download 760 * @crossplatform 761 * @since 10 762 * @name DownloadConfig 763 */ 764 interface DownloadConfig { 765 /** 766 * Resource address. 767 * Verification rule: Starting with http (s)://and with a length not exceeding 2048 characters. 768 * 769 * @syscap SystemCapability.MiscServices.Download 770 * @since 6 771 */ 772 /** 773 * Resource address. 774 * Verification rule: Starting with http (s)://and with a length not exceeding 2048 characters. 775 * 776 * @type { string } 777 * @syscap SystemCapability.MiscServices.Download 778 * @crossplatform 779 * @since 10 780 */ 781 url: string; 782 /** 783 * Adds an HTTP or HTTPS header to be included with the download request. 784 * 785 * @syscap SystemCapability.MiscServices.Download 786 * @since 6 787 */ 788 /** 789 * Adds an HTTP or HTTPS header to be included with the download request. 790 * 791 * @type { ?Object } 792 * @syscap SystemCapability.MiscServices.Download 793 * @crossplatform 794 * @since 10 795 */ 796 header?: Object; 797 /** 798 * Allows download under a metered connection. 799 * 800 * @syscap SystemCapability.MiscServices.Download 801 * @since 6 802 */ 803 /** 804 * Allows download under a metered connection. 805 * 806 * @type { ?boolean } 807 * @syscap SystemCapability.MiscServices.Download 808 * @crossplatform 809 * @since 10 810 */ 811 enableMetered?: boolean; 812 /** 813 * Allows download in a roaming network. 814 * 815 * @syscap SystemCapability.MiscServices.Download 816 * @since 6 817 */ 818 /** 819 * Allows download in a roaming network. 820 * 821 * @type { ?boolean } 822 * @syscap SystemCapability.MiscServices.Download 823 * @crossplatform 824 * @since 10 825 */ 826 enableRoaming?: boolean; 827 /** 828 * Sets the description of a download session. 829 * 830 * @syscap SystemCapability.MiscServices.Download 831 * @since 6 832 */ 833 /** 834 * Sets the description of a download session. 835 * 836 * @type { ?string } 837 * @syscap SystemCapability.MiscServices.Download 838 * @crossplatform 839 * @since 10 840 */ 841 description?: string; 842 /** 843 * Sets the network type allowed for download. 844 * 845 * @syscap SystemCapability.MiscServices.Download 846 * @since 6 847 */ 848 /** 849 * Sets the network type allowed for download. 850 * 851 * @type { ?number } 852 * @syscap SystemCapability.MiscServices.Download 853 * @crossplatform 854 * @since 10 855 */ 856 networkType?: number; 857 /** 858 * Sets the path for downloads. 859 * 860 * @syscap SystemCapability.MiscServices.Download 861 * @since 7 862 */ 863 /** 864 * Sets the path for downloads. 865 * 866 * @type { ?string } 867 * @syscap SystemCapability.MiscServices.Download 868 * @crossplatform 869 * @since 10 870 */ 871 filePath?: string; 872 /** 873 * Sets a download session title. 874 * 875 * @syscap SystemCapability.MiscServices.Download 876 * @since 6 877 */ 878 /** 879 * Sets a download session title. 880 * 881 * @type { ?string } 882 * @syscap SystemCapability.MiscServices.Download 883 * @crossplatform 884 * @since 10 885 */ 886 title?: string; 887 /** 888 * Allow download background task notifications. 889 * 890 * @syscap SystemCapability.MiscServices.Download 891 * @since 9 892 */ 893 /** 894 * Allow download background task notifications. 895 * 896 * @type { ?boolean } 897 * @syscap SystemCapability.MiscServices.Download 898 * @crossplatform 899 * @since 10 900 */ 901 background?: boolean; 902 } 903 904 /** 905 * DownloadInfo data Structure 906 * 907 * @interface DownloadInfo 908 * @syscap SystemCapability.MiscServices.Download 909 * @since 7 910 * @name DownloadInfo 911 */ 912 /** 913 * DownloadInfo data Structure 914 * 915 * @typedef DownloadInfo 916 * @syscap SystemCapability.MiscServices.Download 917 * @crossplatform 918 * @since 10 919 */ 920 interface DownloadInfo { 921 /** 922 * the description of a file to be downloaded. 923 * 924 * @syscap SystemCapability.MiscServices.Download 925 * @since 7 926 */ 927 /** 928 * the description of a file to be downloaded. 929 * 930 * @type { string } 931 * @syscap SystemCapability.MiscServices.Download 932 * @crossplatform 933 * @since 10 934 */ 935 description: string; 936 /** 937 * the real-time downloads size (in bytes). 938 * 939 * @syscap SystemCapability.MiscServices.Download 940 * @since 7 941 */ 942 /** 943 * the real-time downloads size (in bytes). 944 * 945 * @type { number } 946 * @syscap SystemCapability.MiscServices.Download 947 * @crossplatform 948 * @since 10 949 */ 950 downloadedBytes: number; 951 /** 952 * the ID of a file to be downloaded. 953 * 954 * @syscap SystemCapability.MiscServices.Download 955 * @since 7 956 */ 957 /** 958 * the ID of a file to be downloaded. 959 * 960 * @type { number } 961 * @syscap SystemCapability.MiscServices.Download 962 * @crossplatform 963 * @since 10 964 */ 965 downloadId: number; 966 /** 967 * a download failure cause, which can be any DownloadSession.ERROR_* constant. 968 * 969 * @syscap SystemCapability.MiscServices.Download 970 * @since 7 971 */ 972 /** 973 * a download failure cause, which can be any DownloadSession.ERROR_* constant. 974 * 975 * @type { number } 976 * @syscap SystemCapability.MiscServices.Download 977 * @crossplatform 978 * @since 10 979 */ 980 failedReason: number; 981 /** 982 * the name of a file to be downloaded. 983 * 984 * @syscap SystemCapability.MiscServices.Download 985 * @since 7 986 */ 987 /** 988 * the name of a file to be downloaded. 989 * 990 * @type { string } 991 * @syscap SystemCapability.MiscServices.Download 992 * @crossplatform 993 * @since 10 994 */ 995 fileName: string; 996 /** 997 * the URI of a stored file. 998 * 999 * @syscap SystemCapability.MiscServices.Download 1000 * @since 7 1001 */ 1002 /** 1003 * the URI of a stored file. 1004 * 1005 * @type { string } 1006 * @syscap SystemCapability.MiscServices.Download 1007 * @crossplatform 1008 * @since 10 1009 */ 1010 filePath: string; 1011 /** 1012 * the reason why a session is paused, which can be any DownloadSession.PAUSED_* constant. 1013 * 1014 * @syscap SystemCapability.MiscServices.Download 1015 * @since 7 1016 */ 1017 /** 1018 * the reason why a session is paused, which can be any DownloadSession.PAUSED_* constant. 1019 * 1020 * @type { number } 1021 * @syscap SystemCapability.MiscServices.Download 1022 * @crossplatform 1023 * @since 10 1024 */ 1025 pausedReason: number; 1026 /** 1027 * the download status code, which can be any DownloadSession.SESSION_* constant. 1028 * 1029 * @syscap SystemCapability.MiscServices.Download 1030 * @since 7 1031 */ 1032 /** 1033 * the download status code, which can be any DownloadSession.SESSION_* constant. 1034 * 1035 * @type { number } 1036 * @syscap SystemCapability.MiscServices.Download 1037 * @crossplatform 1038 * @since 10 1039 */ 1040 status: number; 1041 /** 1042 * the URI of files to be downloaded. 1043 * 1044 * @syscap SystemCapability.MiscServices.Download 1045 * @since 7 1046 */ 1047 /** 1048 * the URI of files to be downloaded. 1049 * 1050 * @type { string } 1051 * @syscap SystemCapability.MiscServices.Download 1052 * @crossplatform 1053 * @since 10 1054 */ 1055 targetURI: string; 1056 /** 1057 * the title of a file to be downloaded. 1058 * 1059 * @syscap SystemCapability.MiscServices.Download 1060 * @since 7 1061 */ 1062 /** 1063 * the title of a file to be downloaded. 1064 * 1065 * @type { string } 1066 * @syscap SystemCapability.MiscServices.Download 1067 * @crossplatform 1068 * @since 10 1069 */ 1070 downloadTitle: string; 1071 /** 1072 * the total size of files to be downloaded (in bytes). 1073 * 1074 * @syscap SystemCapability.MiscServices.Download 1075 * @since 7 1076 */ 1077 /** 1078 * the total size of files to be downloaded (in bytes). 1079 * 1080 * @type { number } 1081 * @syscap SystemCapability.MiscServices.Download 1082 * @crossplatform 1083 * @since 10 1084 */ 1085 downloadTotalBytes: number; 1086 } 1087 1088 /** 1089 * Download task interface 1090 * 1091 * @interface DownloadTask 1092 * @syscap SystemCapability.MiscServices.Download 1093 * @since 6 1094 */ 1095 /** 1096 * Download task interface 1097 * 1098 * @typedef DownloadTask 1099 * @syscap SystemCapability.MiscServices.Download 1100 * @crossplatform 1101 * @since 10 1102 */ 1103 interface DownloadTask { 1104 /** 1105 * Called when the current download session is in process. 1106 * 1107 * @param { 'progress' } type progress Indicates the download task progress. 1108 * @param { function } callback 1109 * The callback function for the download progress change event 1110 * receivedSize the length of downloaded data, in bytes 1111 * totalSize the length of data expected to be downloaded, in bytes. 1112 * @syscap SystemCapability.MiscServices.Download 1113 * @since 6 1114 */ 1115 /** 1116 * Called when the current download session is in process. 1117 * 1118 * @param { 'progress' } type progress Indicates the download task progress. 1119 * @param { function } callback 1120 * The callback function for the download progress change event 1121 * receivedSize the length of downloaded data, in bytes 1122 * totalSize the length of data expected to be downloaded, in bytes. 1123 * @syscap SystemCapability.MiscServices.Download 1124 * @crossplatform 1125 * @since 10 1126 */ 1127 /** 1128 * Called when the current download session is in process. 1129 * 1130 * @param { 'progress' } type progress Indicates the download task progress. 1131 * @param { function } callback 1132 * <br>The callback function for the download progress change event 1133 * <br>receivedSize the length of downloaded data, in bytes 1134 * <br>totalSize the length of data expected to be downloaded, in bytes. 1135 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 1136 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 1137 * @syscap SystemCapability.MiscServices.Download 1138 * @crossplatform 1139 * @since 12 1140 */ 1141 on(type: 'progress', callback: (receivedSize: number, totalSize: number) => void): void; 1142 1143 /** 1144 * Called when the current download session is in process. 1145 * 1146 * @param { 'progress' } type progress Indicates the download task progress. 1147 * @param { function } [callback] 1148 * The callback function for the download progress change event 1149 * receivedSize the length of downloaded data, in bytes 1150 * totalSize the length of data expected to be downloaded, in bytes. 1151 * @syscap SystemCapability.MiscServices.Download 1152 * @since 6 1153 */ 1154 /** 1155 * Called when the current download session is in process. 1156 * 1157 * @param { 'progress' } type progress Indicates the download task progress. 1158 * @param { function } [callback] 1159 * The callback function for the download progress change event 1160 * receivedSize the length of downloaded data, in bytes 1161 * totalSize the length of data expected to be downloaded, in bytes. 1162 * @syscap SystemCapability.MiscServices.Download 1163 * @crossplatform 1164 * @since 10 1165 */ 1166 /** 1167 * Called when the current download session is in process. 1168 * 1169 * @param { 'progress' } type progress Indicates the download task progress. 1170 * @param { function } [callback] 1171 * <br>The callback function for the download progress change event 1172 * <br>receivedSize the length of downloaded data, in bytes 1173 * <br>totalSize the length of data expected to be downloaded, in bytes. 1174 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 1175 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 1176 * @syscap SystemCapability.MiscServices.Download 1177 * @crossplatform 1178 * @since 12 1179 */ 1180 off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => void): void; 1181 1182 /** 1183 * Called when the current download session complete pause or remove. 1184 * 1185 * @param { 'complete' | 'pause' | 'remove' } type Indicates the download session event type 1186 * complete: download task completed, 1187 * pause: download task stopped, 1188 * remove: download task deleted. 1189 * @param { function } callback The callback function for the download complete pause or remove change event. 1190 * @syscap SystemCapability.MiscServices.Download 1191 * @since 7 1192 */ 1193 /** 1194 * Called when the current download session complete pause or remove. 1195 * 1196 * @param { 'complete' | 'pause' | 'remove' } type Indicates the download session event type 1197 * complete: download task completed, 1198 * pause: download task stopped, 1199 * remove: download task deleted. 1200 * @param { function } callback The callback function for the download complete pause or remove change event. 1201 * @syscap SystemCapability.MiscServices.Download 1202 * @crossplatform 1203 * @since 10 1204 */ 1205 /** 1206 * Called when the current download session complete pause or remove. 1207 * 1208 * @param { 'complete' | 'pause' | 'remove' } type Indicates the download session event type 1209 * <br>complete: download task completed, 1210 * <br>pause: download task stopped, 1211 * <br>remove: download task deleted. 1212 * @param { function } callback The callback function for the download complete pause or remove change event. 1213 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 1214 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 1215 * @syscap SystemCapability.MiscServices.Download 1216 * @crossplatform 1217 * @since 12 1218 */ 1219 on(type: 'complete' | 'pause' | 'remove', callback: () => void): void; 1220 1221 /** 1222 * Called when the current download session complete pause or remove. 1223 * 1224 * @param { 'complete' | 'pause' | 'remove' } type Indicates the download session event type 1225 * complete: download task completed, 1226 * pause: download task stopped, 1227 * remove: download task deleted. 1228 * @param { function } [callback] The callback function for the download complete pause or remove change event. 1229 * @syscap SystemCapability.MiscServices.Download 1230 * @since 7 1231 */ 1232 /** 1233 * Called when the current download session complete pause or remove. 1234 * 1235 * @param { 'complete' | 'pause' | 'remove' } type Indicates the download session event type 1236 * complete: download task completed, 1237 * pause: download task stopped, 1238 * remove: download task deleted. 1239 * @param { function } [callback] The callback function for the download complete pause or remove change event. 1240 * @syscap SystemCapability.MiscServices.Download 1241 * @crossplatform 1242 * @since 10 1243 */ 1244 /** 1245 * Called when the current download session complete pause or remove. 1246 * 1247 * @param { 'complete' | 'pause' | 'remove' } type Indicates the download session event type 1248 * <br>complete: download task completed, 1249 * <br>pause: download task stopped, 1250 * <br>remove: download task deleted. 1251 * @param { function } [callback] The callback function for the download complete pause or remove change event. 1252 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 1253 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 1254 * @syscap SystemCapability.MiscServices.Download 1255 * @crossplatform 1256 * @since 12 1257 */ 1258 off(type: 'complete' | 'pause' | 'remove', callback?: () => void): void; 1259 1260 /** 1261 * Called when the current download session fails. 1262 * 1263 * @param { 'fail' } type Indicates the download session type, fail: download task has failed. 1264 * @param { function } callback The callback function for the download fail change event 1265 * err The error code for download task. 1266 * @syscap SystemCapability.MiscServices.Download 1267 * @since 7 1268 */ 1269 /** 1270 * Called when the current download session fails. 1271 * 1272 * @param { 'fail' } type Indicates the download session type, fail: download task has failed. 1273 * @param { function } callback The callback function for the download fail change event 1274 * err The error code for download task. 1275 * @syscap SystemCapability.MiscServices.Download 1276 * @crossplatform 1277 * @since 10 1278 */ 1279 /** 1280 * Called when the current download session fails. 1281 * 1282 * @param { 'fail' } type Indicates the download session type, fail: download task has failed. 1283 * @param { function } callback The callback function for the download fail change event 1284 * <br>err The error code for download task. 1285 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 1286 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 1287 * @syscap SystemCapability.MiscServices.Download 1288 * @crossplatform 1289 * @since 12 1290 */ 1291 on(type: 'fail', callback: (err: number) => void): void; 1292 1293 /** 1294 * Called when the current download session fails. 1295 * 1296 * @param { 'fail' } type Indicates the download session type, fail: download task has failed. 1297 * @param { function } [callback] Indicate the callback function to receive err. 1298 * err The error code for download task. 1299 * @syscap SystemCapability.MiscServices.Download 1300 * @since 7 1301 */ 1302 /** 1303 * Called when the current download session fails. 1304 * 1305 * @param { 'fail' } type Indicates the download session type, fail: download task has failed. 1306 * @param { function } [callback] Indicate the callback function to receive err. 1307 * err The error code for download task. 1308 * @syscap SystemCapability.MiscServices.Download 1309 * @crossplatform 1310 * @since 10 1311 */ 1312 /** 1313 * Called when the current download session fails. 1314 * 1315 * @param { 'fail' } type Indicates the download session type, fail: download task has failed. 1316 * @param { function } [callback] Indicate the callback function to receive err. 1317 * <br>err The error code for download task. 1318 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 1319 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 1320 * @syscap SystemCapability.MiscServices.Download 1321 * @crossplatform 1322 * @since 12 1323 */ 1324 off(type: 'fail', callback?: (err: number) => void): void; 1325 1326 /** 1327 * Deletes a download session and the downloaded files. 1328 * 1329 * @permission ohos.permission.INTERNET 1330 * @param { AsyncCallback<boolean> } callback Indicates asynchronous invoking Result. 1331 * @throws { BusinessError } 201 - the permissions check fails 1332 * @syscap SystemCapability.MiscServices.Download 1333 * @since 6 1334 * @deprecated since 9 1335 * @useinstead ohos.request.delete 1336 */ 1337 remove(callback: AsyncCallback<boolean>): void; 1338 1339 /** 1340 * Deletes a download session and the downloaded files. 1341 * 1342 * @permission ohos.permission.INTERNET 1343 * @returns { Promise<boolean> } the promise returned by the function. 1344 * @throws { BusinessError } 201 - the permissions check fails 1345 * @syscap SystemCapability.MiscServices.Download 1346 * @since 6 1347 * @deprecated since 9 1348 * @useinstead ohos.request.delete 1349 */ 1350 remove(): Promise<boolean>; 1351 1352 /** 1353 * Pause a download session. 1354 * 1355 * @permission ohos.permission.INTERNET 1356 * @param { AsyncCallback<void> } callback Indicates asynchronous invoking Result. 1357 * @throws { BusinessError } 201 - the permissions check fails 1358 * @syscap SystemCapability.MiscServices.Download 1359 * @since 7 1360 * @deprecated since 9 1361 * @useinstead ohos.request.suspend 1362 */ 1363 pause(callback: AsyncCallback<void>): void; 1364 1365 /** 1366 * Pause a download session. 1367 * 1368 * @permission ohos.permission.INTERNET 1369 * @returns { Promise<void> } the promise returned by the function. 1370 * @throws { BusinessError } 201 - the permissions check fails 1371 * @syscap SystemCapability.MiscServices.Download 1372 * @since 7 1373 * @deprecated since 9 1374 * @useinstead ohos.request.suspend 1375 */ 1376 pause(): Promise<void>; 1377 1378 /** 1379 * Resume a paused download session. 1380 * 1381 * @permission ohos.permission.INTERNET 1382 * @param { AsyncCallback<void> } callback Indicates asynchronous invoking Result. 1383 * @throws { BusinessError } 201 - the permissions check fails 1384 * @syscap SystemCapability.MiscServices.Download 1385 * @since 7 1386 * @deprecated since 9 1387 * @useinstead ohos.request.restore 1388 */ 1389 resume(callback: AsyncCallback<void>): void; 1390 1391 /** 1392 * Resume a paused download session. 1393 * 1394 * @permission ohos.permission.INTERNET 1395 * @returns { Promise<void> } the promise returned by the function. 1396 * @throws { BusinessError } 201 - the permissions check fails 1397 * @syscap SystemCapability.MiscServices.Download 1398 * @since 7 1399 * @deprecated since 9 1400 * @useinstead ohos.request.restore 1401 */ 1402 resume(): Promise<void>; 1403 1404 /** 1405 * Queries download information of a session, which is defined in DownloadSession.DownloadInfo. 1406 * 1407 * @permission ohos.permission.INTERNET 1408 * @param { AsyncCallback<DownloadInfo> } callback Indicate the callback function to receive download info. 1409 * @throws { BusinessError } 201 - the permissions check fails 1410 * @syscap SystemCapability.MiscServices.Download 1411 * @since 7 1412 * @deprecated since 9 1413 * @useinstead ohos.request.getTaskInfo 1414 */ 1415 query(callback: AsyncCallback<DownloadInfo>): void; 1416 1417 /** 1418 * Queries download information of a session, which is defined in DownloadSession.DownloadInfo. 1419 * 1420 * @permission ohos.permission.INTERNET 1421 * @returns { Promise<DownloadInfo> } the promise returned by the function. 1422 * @throws { BusinessError } 201 - the permissions check fails 1423 * @syscap SystemCapability.MiscServices.Download 1424 * @since 7 1425 * @deprecated since 9 1426 * @useinstead ohos.request.getTaskInfo 1427 */ 1428 query(): Promise<DownloadInfo>; 1429 1430 /** 1431 * Queries the MIME type of the download file. 1432 * 1433 * @permission ohos.permission.INTERNET 1434 * @param { AsyncCallback<string> } callback Indicate the callback function to receive download file MIME type. 1435 * @throws { BusinessError } 201 - the permissions check fails 1436 * @syscap SystemCapability.MiscServices.Download 1437 * @since 7 1438 * @deprecated since 9 1439 * @useinstead ohos.request.getTaskMimeType 1440 */ 1441 queryMimeType(callback: AsyncCallback<string>): void; 1442 1443 /** 1444 * Queries the MIME type of the download file. 1445 * 1446 * @permission ohos.permission.INTERNET 1447 * @returns { Promise<string> } the promise returned by the function. 1448 * @throws { BusinessError } 201 - the permissions check fails 1449 * @syscap SystemCapability.MiscServices.Download 1450 * @since 7 1451 * @deprecated since 9 1452 * @useinstead ohos.request.getTaskMimeType 1453 */ 1454 queryMimeType(): Promise<string>; 1455 1456 /** 1457 * Delete the download task 1458 * 1459 * @permission ohos.permission.INTERNET 1460 * @param { AsyncCallback<boolean> } callback 1461 * @throws { BusinessError } 201 - the permissions check fails 1462 * @throws { BusinessError } 401 - the parameters check fails 1463 * @syscap SystemCapability.MiscServices.Download 1464 * @since 9 1465 */ 1466 /** 1467 * Delete the download task 1468 * 1469 * @permission ohos.permission.INTERNET 1470 * @param { AsyncCallback<boolean> } callback 1471 * @throws { BusinessError } 201 - the permissions check fails 1472 * @throws { BusinessError } 401 - the parameters check fails 1473 * @syscap SystemCapability.MiscServices.Download 1474 * @crossplatform 1475 * @since 10 1476 */ 1477 /** 1478 * Delete the download task 1479 * 1480 * @permission ohos.permission.INTERNET 1481 * @param { AsyncCallback<boolean> } callback 1482 * @throws { BusinessError } 201 - the permissions check fails 1483 * @syscap SystemCapability.MiscServices.Download 1484 * @crossplatform 1485 * @since 12 1486 */ 1487 delete(callback: AsyncCallback<boolean>): void; 1488 1489 /** 1490 * Delete the download task 1491 * 1492 * @permission ohos.permission.INTERNET 1493 * @returns { Promise<boolean> } the promise returned by the function. 1494 * @throws { BusinessError } 201 - the permissions check fails 1495 * @throws { BusinessError } 401 - the parameters check fails 1496 * @syscap SystemCapability.MiscServices.Download 1497 * @since 9 1498 */ 1499 /** 1500 * Delete the download task 1501 * 1502 * @permission ohos.permission.INTERNET 1503 * @returns { Promise<boolean> } the promise returned by the function. 1504 * @throws { BusinessError } 201 - the permissions check fails 1505 * @throws { BusinessError } 401 - the parameters check fails 1506 * @syscap SystemCapability.MiscServices.Download 1507 * @crossplatform 1508 * @since 10 1509 */ 1510 /** 1511 * Delete the download task 1512 * 1513 * @permission ohos.permission.INTERNET 1514 * @returns { Promise<boolean> } the promise returned by the function. 1515 * @throws { BusinessError } 201 - the permissions check fails 1516 * @syscap SystemCapability.MiscServices.Download 1517 * @crossplatform 1518 * @since 12 1519 */ 1520 delete(): Promise<boolean>; 1521 1522 /** 1523 * Suspend the download task 1524 * 1525 * @permission ohos.permission.INTERNET 1526 * @param { AsyncCallback<boolean> } callback 1527 * @throws { BusinessError } 201 - the permissions check fails 1528 * @throws { BusinessError } 401 - the parameters check fails 1529 * @syscap SystemCapability.MiscServices.Download 1530 * @since 9 1531 */ 1532 /** 1533 * Suspend the download task 1534 * 1535 * @permission ohos.permission.INTERNET 1536 * @param { AsyncCallback<boolean> } callback 1537 * @throws { BusinessError } 201 - the permissions check fails 1538 * @throws { BusinessError } 401 - the parameters check fails 1539 * @syscap SystemCapability.MiscServices.Download 1540 * @crossplatform 1541 * @since 10 1542 */ 1543 /** 1544 * Suspend the download task 1545 * 1546 * @permission ohos.permission.INTERNET 1547 * @param { AsyncCallback<boolean> } callback 1548 * @throws { BusinessError } 201 - the permissions check fails 1549 * @syscap SystemCapability.MiscServices.Download 1550 * @crossplatform 1551 * @since 12 1552 */ 1553 suspend(callback: AsyncCallback<boolean>): void; 1554 1555 /** 1556 * Suspend the download task 1557 * 1558 * @permission ohos.permission.INTERNET 1559 * @returns { Promise<boolean> } the promise returned by the function. 1560 * @throws { BusinessError } 201 - the permissions check fails 1561 * @throws { BusinessError } 401 - the parameters check fails 1562 * @syscap SystemCapability.MiscServices.Download 1563 * @since 9 1564 */ 1565 /** 1566 * Suspend the download task 1567 * 1568 * @permission ohos.permission.INTERNET 1569 * @returns { Promise<boolean> } the promise returned by the function. 1570 * @throws { BusinessError } 201 - the permissions check fails 1571 * @throws { BusinessError } 401 - the parameters check fails 1572 * @syscap SystemCapability.MiscServices.Download 1573 * @crossplatform 1574 * @since 10 1575 */ 1576 /** 1577 * Suspend the download task 1578 * 1579 * @permission ohos.permission.INTERNET 1580 * @returns { Promise<boolean> } the promise returned by the function. 1581 * @throws { BusinessError } 201 - the permissions check fails 1582 * @syscap SystemCapability.MiscServices.Download 1583 * @crossplatform 1584 * @since 12 1585 */ 1586 suspend(): Promise<boolean>; 1587 1588 /** 1589 * Restore the download task 1590 * 1591 * @permission ohos.permission.INTERNET 1592 * @param { AsyncCallback<boolean> } callback 1593 * @throws { BusinessError } 201 - the permissions check fails 1594 * @throws { BusinessError } 401 - the parameters check fails 1595 * @syscap SystemCapability.MiscServices.Download 1596 * @since 9 1597 */ 1598 /** 1599 * Restore the download task 1600 * 1601 * @permission ohos.permission.INTERNET 1602 * @param { AsyncCallback<boolean> } callback 1603 * @throws { BusinessError } 201 - the permissions check fails 1604 * @throws { BusinessError } 401 - the parameters check fails 1605 * @syscap SystemCapability.MiscServices.Download 1606 * @crossplatform 1607 * @since 10 1608 */ 1609 /** 1610 * Restore the download task 1611 * 1612 * @permission ohos.permission.INTERNET 1613 * @param { AsyncCallback<boolean> } callback 1614 * @throws { BusinessError } 201 - the permissions check fails 1615 * @syscap SystemCapability.MiscServices.Download 1616 * @crossplatform 1617 * @since 12 1618 */ 1619 restore(callback: AsyncCallback<boolean>): void; 1620 1621 /** 1622 * Restore the download task 1623 * 1624 * @permission ohos.permission.INTERNET 1625 * @returns { Promise<boolean> } the promise returned by the function. 1626 * @throws { BusinessError } 201 - the permissions check fails 1627 * @throws { BusinessError } 401 - the parameters check fails 1628 * @syscap SystemCapability.MiscServices.Download 1629 * @since 9 1630 */ 1631 /** 1632 * Restore the download task 1633 * 1634 * @permission ohos.permission.INTERNET 1635 * @returns { Promise<boolean> } the promise returned by the function. 1636 * @throws { BusinessError } 201 - the permissions check fails 1637 * @throws { BusinessError } 401 - the parameters check fails 1638 * @syscap SystemCapability.MiscServices.Download 1639 * @crossplatform 1640 * @since 10 1641 */ 1642 /** 1643 * Restore the download task 1644 * 1645 * @permission ohos.permission.INTERNET 1646 * @returns { Promise<boolean> } the promise returned by the function. 1647 * @throws { BusinessError } 201 - the permissions check fails 1648 * @syscap SystemCapability.MiscServices.Download 1649 * @crossplatform 1650 * @since 12 1651 */ 1652 restore(): Promise<boolean>; 1653 1654 /** 1655 * Get the download task info 1656 * 1657 * @permission ohos.permission.INTERNET 1658 * @param { AsyncCallback<DownloadInfo> } callback 1659 * @throws { BusinessError } 201 - the permissions check fails 1660 * @throws { BusinessError } 401 - the parameters check fails 1661 * @syscap SystemCapability.MiscServices.Download 1662 * @since 9 1663 */ 1664 /** 1665 * Get the download task info 1666 * 1667 * @permission ohos.permission.INTERNET 1668 * @param { AsyncCallback<DownloadInfo> } callback 1669 * @throws { BusinessError } 201 - the permissions check fails 1670 * @throws { BusinessError } 401 - the parameters check fails 1671 * @syscap SystemCapability.MiscServices.Download 1672 * @crossplatform 1673 * @since 10 1674 */ 1675 /** 1676 * Get the download task info 1677 * 1678 * @permission ohos.permission.INTERNET 1679 * @param { AsyncCallback<DownloadInfo> } callback 1680 * @throws { BusinessError } 201 - the permissions check fails 1681 * @syscap SystemCapability.MiscServices.Download 1682 * @crossplatform 1683 * @since 12 1684 */ 1685 getTaskInfo(callback: AsyncCallback<DownloadInfo>): void; 1686 1687 /** 1688 * Get the download task info 1689 * 1690 * @permission ohos.permission.INTERNET 1691 * @returns { Promise<DownloadInfo> } the promise returned by the function. 1692 * @throws { BusinessError } 201 - the permissions check fails 1693 * @throws { BusinessError } 401 - the parameters check fails 1694 * @syscap SystemCapability.MiscServices.Download 1695 * @since 9 1696 */ 1697 /** 1698 * Get the download task info 1699 * 1700 * @permission ohos.permission.INTERNET 1701 * @returns { Promise<DownloadInfo> } the promise returned by the function. 1702 * @throws { BusinessError } 201 - the permissions check fails 1703 * @throws { BusinessError } 401 - the parameters check fails 1704 * @syscap SystemCapability.MiscServices.Download 1705 * @crossplatform 1706 * @since 10 1707 */ 1708 /** 1709 * Get the download task info 1710 * 1711 * @permission ohos.permission.INTERNET 1712 * @returns { Promise<DownloadInfo> } the promise returned by the function. 1713 * @throws { BusinessError } 201 - the permissions check fails 1714 * @syscap SystemCapability.MiscServices.Download 1715 * @crossplatform 1716 * @since 12 1717 */ 1718 getTaskInfo(): Promise<DownloadInfo>; 1719 1720 /** 1721 * Get mimetype of the download task 1722 * 1723 * @permission ohos.permission.INTERNET 1724 * @param { AsyncCallback<string> } callback 1725 * @throws { BusinessError } 201 - the permissions check fails 1726 * @throws { BusinessError } 401 - the parameters check fails 1727 * @syscap SystemCapability.MiscServices.Download 1728 * @since 9 1729 */ 1730 /** 1731 * Get mimetype of the download task 1732 * 1733 * @permission ohos.permission.INTERNET 1734 * @param { AsyncCallback<string> } callback 1735 * @throws { BusinessError } 201 - the permissions check fails 1736 * @throws { BusinessError } 401 - the parameters check fails 1737 * @syscap SystemCapability.MiscServices.Download 1738 * @crossplatform 1739 * @since 10 1740 */ 1741 /** 1742 * Get mimetype of the download task 1743 * 1744 * @permission ohos.permission.INTERNET 1745 * @param { AsyncCallback<string> } callback 1746 * @throws { BusinessError } 201 - the permissions check fails 1747 * @syscap SystemCapability.MiscServices.Download 1748 * @crossplatform 1749 * @since 12 1750 */ 1751 getTaskMimeType(callback: AsyncCallback<string>): void; 1752 1753 /** 1754 * Get mimetype of the download task 1755 * 1756 * @permission ohos.permission.INTERNET 1757 * @returns { Promise<string> } the promise returned by the function. 1758 * @throws { BusinessError } 201 - the permissions check fails 1759 * @throws { BusinessError } 401 - the parameters check fails 1760 * @syscap SystemCapability.MiscServices.Download 1761 * @since 9 1762 */ 1763 /** 1764 * Get mimetype of the download task 1765 * 1766 * @permission ohos.permission.INTERNET 1767 * @returns { Promise<string> } the promise returned by the function. 1768 * @throws { BusinessError } 201 - the permissions check fails 1769 * @throws { BusinessError } 401 - the parameters check fails 1770 * @syscap SystemCapability.MiscServices.Download 1771 * @crossplatform 1772 * @since 10 1773 */ 1774 /** 1775 * Get mimetype of the download task 1776 * 1777 * @permission ohos.permission.INTERNET 1778 * @returns { Promise<string> } the promise returned by the function. 1779 * @throws { BusinessError } 201 - the permissions check fails 1780 * @syscap SystemCapability.MiscServices.Download 1781 * @crossplatform 1782 * @since 12 1783 */ 1784 getTaskMimeType(): Promise<string>; 1785 } 1786 1787 /** 1788 * File data Structure 1789 * 1790 * @interface File 1791 * @syscap SystemCapability.MiscServices.Download 1792 * @since 6 1793 * @name File 1794 */ 1795 /** 1796 * File data Structure 1797 * 1798 * @typedef File 1799 * @syscap SystemCapability.MiscServices.Download 1800 * @crossplatform 1801 * @since 10 1802 */ 1803 interface File { 1804 /** 1805 * When multipart is submitted, the file name in the request header. 1806 * 1807 * @syscap SystemCapability.MiscServices.Download 1808 * @since 6 1809 */ 1810 /** 1811 * When multipart is submitted, the file name in the request header. 1812 * 1813 * @type { string } 1814 * @syscap SystemCapability.MiscServices.Download 1815 * @crossplatform 1816 * @since 10 1817 */ 1818 filename: string; 1819 /** 1820 * When multipart is submitted, the name of the form item. The default is file. 1821 * 1822 * @syscap SystemCapability.MiscServices.Download 1823 * @since 6 1824 */ 1825 /** 1826 * When multipart is submitted, the name of the form item. The default is file. 1827 * 1828 * @type { string } 1829 * @syscap SystemCapability.MiscServices.Download 1830 * @crossplatform 1831 * @since 10 1832 */ 1833 name: string; 1834 /** 1835 * The local storage path of the file (please refer to the storage directory definition for path usage). 1836 * 1837 * @syscap SystemCapability.MiscServices.Download 1838 * @since 6 1839 */ 1840 /** 1841 * The local storage path of the file (please refer to the storage directory definition for path usage). 1842 * 1843 * @type { string } 1844 * @syscap SystemCapability.MiscServices.Download 1845 * @crossplatform 1846 * @since 10 1847 */ 1848 uri: string; 1849 /** 1850 * The content type of the file is obtained by default according to the suffix of the file name or path. 1851 * 1852 * @syscap SystemCapability.MiscServices.Download 1853 * @since 6 1854 */ 1855 /** 1856 * The content type of the file is obtained by default according to the suffix of the file name or path. 1857 * 1858 * @type { string } 1859 * @syscap SystemCapability.MiscServices.Download 1860 * @crossplatform 1861 * @since 10 1862 */ 1863 type: string; 1864 } 1865 1866 /** 1867 * RequestData data Structure 1868 * 1869 * @interface RequestData 1870 * @syscap SystemCapability.MiscServices.Download 1871 * @since 6 1872 * @name RequestData 1873 */ 1874 /** 1875 * RequestData data Structure 1876 * 1877 * @typedef RequestData 1878 * @syscap SystemCapability.MiscServices.Download 1879 * @crossplatform 1880 * @since 10 1881 */ 1882 interface RequestData { 1883 /** 1884 * Represents the name of the form element. 1885 * 1886 * @syscap SystemCapability.MiscServices.Download 1887 * @since 6 1888 */ 1889 /** 1890 * Represents the name of the form element. 1891 * 1892 * @type { string } 1893 * @syscap SystemCapability.MiscServices.Download 1894 * @crossplatform 1895 * @since 10 1896 */ 1897 name: string; 1898 /** 1899 * Represents the value of the form element. 1900 * 1901 * @syscap SystemCapability.MiscServices.Download 1902 * @since 6 1903 */ 1904 /** 1905 * Represents the value of the form element. 1906 * 1907 * @type { string } 1908 * @syscap SystemCapability.MiscServices.Download 1909 * @crossplatform 1910 * @since 10 1911 */ 1912 value: string; 1913 } 1914 1915 /** 1916 * UploadConfig data Structure 1917 * 1918 * @interface UploadConfig 1919 * @syscap SystemCapability.MiscServices.Upload 1920 * @since 6 1921 * @name UploadConfig 1922 */ 1923 /** 1924 * UploadConfig data Structure 1925 * 1926 * @typedef UploadConfig 1927 * @syscap SystemCapability.MiscServices.Upload 1928 * @crossplatform 1929 * @since 10 1930 */ 1931 interface UploadConfig { 1932 /** 1933 * Resource address. 1934 * Verification rule: Starting with http (s)://and with a length not exceeding 2048 characters. 1935 * 1936 * @syscap SystemCapability.MiscServices.Upload 1937 * @since 6 1938 */ 1939 /** 1940 * Resource address. 1941 * Verification rule: Starting with http (s)://and with a length not exceeding 2048 characters. 1942 * 1943 * @type { string } 1944 * @syscap SystemCapability.MiscServices.Upload 1945 * @crossplatform 1946 * @since 10 1947 */ 1948 url: string; 1949 /** 1950 * Adds an HTTP or HTTPS header to be included with the upload request. 1951 * 1952 * @syscap SystemCapability.MiscServices.Upload 1953 * @since 6 1954 */ 1955 /** 1956 * Adds an HTTP or HTTPS header to be included with the upload request. 1957 * 1958 * @type { Object } 1959 * @syscap SystemCapability.MiscServices.Upload 1960 * @crossplatform 1961 * @since 10 1962 */ 1963 header: Object; 1964 /** 1965 * Request method: POST, PUT. The default POST. 1966 * 1967 * @syscap SystemCapability.MiscServices.Upload 1968 * @since 6 1969 */ 1970 /** 1971 * Request method: POST, PUT. The default POST. 1972 * 1973 * @type { string } 1974 * @syscap SystemCapability.MiscServices.Upload 1975 * @crossplatform 1976 * @since 10 1977 */ 1978 method: string; 1979 /** 1980 * The index of paths for a task. 1981 * Usually used for a continuous job. 1982 * The default is 0. 1983 * 1984 * @type { ?number } 1985 * @syscap SystemCapability.MiscServices.Upload 1986 * @since 11 1987 */ 1988 index?: number; 1989 /** 1990 * The start point of a file. 1991 * Usually used for a continuous job. 1992 * It will start read at the point in upload. 1993 * The default is 0. 1994 * 1995 * @type { ?number } 1996 * @syscap SystemCapability.MiscServices.Upload 1997 * @since 11 1998 */ 1999 begins?: number; 2000 /** 2001 * The end point of a file. 2002 * Usually used for a continuous job. 2003 * It will end read at the point in upload. 2004 * The default is -1 indicating the end of the data for upload. 2005 * 2006 * @type { ?number } 2007 * @syscap SystemCapability.MiscServices.Upload 2008 * @since 11 2009 */ 2010 ends?: number; 2011 /** 2012 * A list of files to be uploaded. Please use multipart/form-data to submit. 2013 * 2014 * @syscap SystemCapability.MiscServices.Upload 2015 * @since 6 2016 */ 2017 /** 2018 * A list of files to be uploaded. Please use multipart/form-data to submit. 2019 * 2020 * @type { Array<File> } 2021 * @syscap SystemCapability.MiscServices.Upload 2022 * @crossplatform 2023 * @since 10 2024 */ 2025 files: Array<File>; 2026 /** 2027 * The requested form data. 2028 * 2029 * @syscap SystemCapability.MiscServices.Upload 2030 * @since 6 2031 */ 2032 /** 2033 * The requested form data. 2034 * 2035 * @type { Array<RequestData> } 2036 * @syscap SystemCapability.MiscServices.Upload 2037 * @crossplatform 2038 * @since 10 2039 */ 2040 data: Array<RequestData>; 2041 } 2042 2043 /** 2044 * TaskState data Structure 2045 * 2046 * @interface TaskState 2047 * @syscap SystemCapability.MiscServices.Upload 2048 * @since 9 2049 * @name TaskState 2050 */ 2051 /** 2052 * TaskState data Structure 2053 * 2054 * @typedef TaskState 2055 * @syscap SystemCapability.MiscServices.Upload 2056 * @crossplatform 2057 * @since 10 2058 */ 2059 interface TaskState { 2060 /** 2061 * Upload file path. 2062 * 2063 * @syscap SystemCapability.MiscServices.Upload 2064 * @since 9 2065 */ 2066 /** 2067 * Upload file path. 2068 * 2069 * @type { string } 2070 * @syscap SystemCapability.MiscServices.Upload 2071 * @crossplatform 2072 * @since 10 2073 */ 2074 path: string; 2075 /** 2076 * Upload task return value. 2077 * 2078 * @syscap SystemCapability.MiscServices.Upload 2079 * @since 9 2080 */ 2081 /** 2082 * Upload task return value. 2083 * 2084 * @type { number } 2085 * @syscap SystemCapability.MiscServices.Upload 2086 * @crossplatform 2087 * @since 10 2088 */ 2089 responseCode: number; 2090 /** 2091 * Upload task information. 2092 * 2093 * @syscap SystemCapability.MiscServices.Upload 2094 * @since 9 2095 */ 2096 /** 2097 * Upload task information. 2098 * 2099 * @type { string } 2100 * @syscap SystemCapability.MiscServices.Upload 2101 * @crossplatform 2102 * @since 10 2103 */ 2104 message: string; 2105 } 2106 2107 /** 2108 * Upload task interface 2109 * 2110 * @interface UploadTask 2111 * @syscap SystemCapability.MiscServices.Download 2112 * @since 6 2113 */ 2114 /** 2115 * Upload task interface 2116 * 2117 * @typedef UploadTask 2118 * @syscap SystemCapability.MiscServices.Download 2119 * @crossplatform 2120 * @since 10 2121 */ 2122 interface UploadTask { 2123 /** 2124 * Called when the current upload session is in process. 2125 * 2126 * @param { 'progress' } type progress Indicates the upload task progress. 2127 * @param { function } callback 2128 * The callback function for the upload progress change event 2129 * uploadedSize The length of uploaded data, in bytes 2130 * totalSize The length of data expected to be uploaded, in bytes. 2131 * @syscap SystemCapability.MiscServices.Upload 2132 * @since 6 2133 */ 2134 /** 2135 * Called when the current upload session is in process. 2136 * 2137 * @param { 'progress' } type progress Indicates the upload task progress. 2138 * @param { function } callback 2139 * The callback function for the upload progress change event 2140 * uploadedSize The length of uploaded data, in bytes 2141 * totalSize The length of data expected to be uploaded, in bytes. 2142 * @syscap SystemCapability.MiscServices.Upload 2143 * @crossplatform 2144 * @since 10 2145 */ 2146 /** 2147 * Called when the current upload session is in process. 2148 * 2149 * @param { 'progress' } type progress Indicates the upload task progress. 2150 * @param { function } callback 2151 * <br>The callback function for the upload progress change event 2152 * <br>uploadedSize The length of uploaded data, in bytes 2153 * <br>totalSize The length of data expected to be uploaded, in bytes. 2154 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 2155 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 2156 * @syscap SystemCapability.MiscServices.Upload 2157 * @crossplatform 2158 * @since 12 2159 */ 2160 on(type: 'progress', callback: (uploadedSize: number, totalSize: number) => void): void; 2161 2162 /** 2163 * Called when the current upload session is in process. 2164 * 2165 * @param { 'progress' } type progress Indicates the upload task progress. 2166 * @param { function } [callback] 2167 * The callback function for the upload progress change event 2168 * uploadedSize The length of uploaded data, in bytes 2169 * totalSize The length of data expected to be uploaded, in bytes. 2170 * @syscap SystemCapability.MiscServices.Upload 2171 * @since 6 2172 */ 2173 /** 2174 * Called when the current upload session is in process. 2175 * 2176 * @param { 'progress' } type progress Indicates the upload task progress. 2177 * @param { function } [callback] 2178 * The callback function for the upload progress change event 2179 * uploadedSize The length of uploaded data, in bytes 2180 * totalSize The length of data expected to be uploaded, in bytes. 2181 * @syscap SystemCapability.MiscServices.Upload 2182 * @crossplatform 2183 * @since 10 2184 */ 2185 /** 2186 * Called when the current upload session is in process. 2187 * 2188 * @param { 'progress' } type progress Indicates the upload task progress. 2189 * @param { function } [callback] 2190 * <br>The callback function for the upload progress change event 2191 * <br>uploadedSize The length of uploaded data, in bytes 2192 * <br>totalSize The length of data expected to be uploaded, in bytes. 2193 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 2194 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 2195 * @syscap SystemCapability.MiscServices.Upload 2196 * @crossplatform 2197 * @since 12 2198 */ 2199 off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => void): void; 2200 2201 /** 2202 * Called when the header of the current upload session has been received. 2203 * 2204 * @param { 'headerReceive' } type headerReceive Indicates the upload task headed receive. 2205 * @param { function } callback The callback function for the HTTP Response Header event 2206 * header HTTP Response Header returned by the developer server. 2207 * @syscap SystemCapability.MiscServices.Upload 2208 * @since 7 2209 */ 2210 /** 2211 * Called when the header of the current upload session has been received. 2212 * 2213 * @param { 'headerReceive' } type headerReceive Indicates the upload task headed receive. 2214 * @param { function } callback The callback function for the HTTP Response Header event 2215 * header HTTP Response Header returned by the developer server. 2216 * @syscap SystemCapability.MiscServices.Upload 2217 * @crossplatform 2218 * @since 10 2219 */ 2220 /** 2221 * Called when the header of the current upload session has been received. 2222 * 2223 * @param { 'headerReceive' } type headerReceive Indicates the upload task headed receive. 2224 * @param { function } callback The callback function for the HTTP Response Header event 2225 * <br>header HTTP Response Header returned by the developer server. 2226 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 2227 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 2228 * @syscap SystemCapability.MiscServices.Upload 2229 * @crossplatform 2230 * @since 12 2231 */ 2232 on(type: 'headerReceive', callback: (header: object) => void): void; 2233 2234 /** 2235 * Called when the header of the current upload session has been received. 2236 * 2237 * @param { 'headerReceive' } type headerReceive Indicates the upload task headed receive. 2238 * @param { function } [callback] The callback function for the HTTP Response Header event 2239 * header HTTP Response Header returned by the developer server. 2240 * @syscap SystemCapability.MiscServices.Upload 2241 * @since 7 2242 */ 2243 /** 2244 * Called when the header of the current upload session has been received. 2245 * 2246 * @param { 'headerReceive' } type headerReceive Indicates the upload task headed receive. 2247 * @param { function } [callback] The callback function for the HTTP Response Header event 2248 * header HTTP Response Header returned by the developer server. 2249 * @syscap SystemCapability.MiscServices.Upload 2250 * @crossplatform 2251 * @since 10 2252 */ 2253 /** 2254 * Called when the header of the current upload session has been received. 2255 * 2256 * @param { 'headerReceive' } type headerReceive Indicates the upload task headed receive. 2257 * @param { function } [callback] The callback function for the HTTP Response Header event 2258 * <br>header HTTP Response Header returned by the developer server. 2259 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 2260 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 2261 * @syscap SystemCapability.MiscServices.Upload 2262 * @crossplatform 2263 * @since 12 2264 */ 2265 off(type: 'headerReceive', callback?: (header: object) => void): void; 2266 2267 /** 2268 * Called when the current upload session complete or fail. 2269 * 2270 * @param { 'complete' | 'fail' } type Indicates the upload session event type 2271 * complete: upload task completed 2272 * fail: upload task failed 2273 * @param { Callback<Array<TaskState>> } callback The callback function for the upload complete or fail change event. 2274 * @syscap SystemCapability.MiscServices.Upload 2275 * @since 9 2276 */ 2277 /** 2278 * Called when the current upload session complete or fail. 2279 * 2280 * @param { 'complete' | 'fail' } type Indicates the upload session event type 2281 * complete: upload task completed 2282 * fail: upload task failed 2283 * @param { Callback<Array<TaskState>> } callback The callback function for the upload complete or fail change event. 2284 * @syscap SystemCapability.MiscServices.Upload 2285 * @crossplatform 2286 * @since 10 2287 */ 2288 /** 2289 * Called when the current upload session complete or fail. 2290 * 2291 * @param { 'complete' | 'fail' } type Indicates the upload session event type 2292 * <br>complete: upload task completed 2293 * <br>fail: upload task failed 2294 * @param { Callback<Array<TaskState>> } callback The callback function for the upload complete or fail change event. 2295 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 2296 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 2297 * @syscap SystemCapability.MiscServices.Upload 2298 * @crossplatform 2299 * @since 12 2300 */ 2301 on(type: 'complete' | 'fail', callback: Callback<Array<TaskState>>): void; 2302 2303 /** 2304 * Called when the current upload session complete or fail. 2305 * 2306 * @param { 'complete' | 'fail' } type Indicates the upload session event type 2307 * complete: upload task completed 2308 * fail: upload task failed 2309 * @param { Callback<Array<TaskState>> } [callback] 2310 * @syscap SystemCapability.MiscServices.Upload 2311 * @since 9 2312 */ 2313 /** 2314 * Called when the current upload session complete or fail. 2315 * 2316 * @param { 'complete' | 'fail' } type Indicates the upload session event type 2317 * complete: upload task completed 2318 * fail: upload task failed 2319 * @param { Callback<Array<TaskState>> } [callback] 2320 * @syscap SystemCapability.MiscServices.Upload 2321 * @crossplatform 2322 * @since 10 2323 */ 2324 /** 2325 * Called when the current upload session complete or fail. 2326 * 2327 * @param { 'complete' | 'fail' } type Indicates the upload session event type 2328 * <br>complete: upload task completed 2329 * <br>fail: upload task failed 2330 * @param { Callback<Array<TaskState>> } [callback] 2331 * @throws { BusinessError } 401 - the parameters check fails. Possible causes: 1. Missing mandatory parameters. 2332 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 2333 * @syscap SystemCapability.MiscServices.Upload 2334 * @crossplatform 2335 * @since 12 2336 */ 2337 off(type: 'complete' | 'fail', callback?: Callback<Array<TaskState>>): void; 2338 2339 /** 2340 * Deletes an upload session. 2341 * 2342 * @permission ohos.permission.INTERNET 2343 * @param { AsyncCallback<boolean> } callback Indicates asynchronous invoking Result. 2344 * @throws { BusinessError } 201 - the permissions check fails 2345 * @syscap SystemCapability.MiscServices.Upload 2346 * @since 6 2347 * @deprecated since 9 2348 * @useinstead ohos.request.delete 2349 */ 2350 remove(callback: AsyncCallback<boolean>): void; 2351 2352 /** 2353 * Deletes an upload session. 2354 * 2355 * @permission ohos.permission.INTERNET 2356 * @returns { Promise<boolean> } the promise returned by the function. 2357 * @throws { BusinessError } 201 - the permissions check fails 2358 * @syscap SystemCapability.MiscServices.Upload 2359 * @since 6 2360 * @deprecated since 9 2361 * @useinstead ohos.request.delete 2362 */ 2363 remove(): Promise<boolean>; 2364 2365 /** 2366 * Delete the upload task 2367 * 2368 * @permission ohos.permission.INTERNET 2369 * @param { AsyncCallback<boolean> } callback 2370 * @throws { BusinessError } 201 - the permissions check fails 2371 * @throws { BusinessError } 401 - the parameters check fails 2372 * @syscap SystemCapability.MiscServices.Upload 2373 * @since 9 2374 */ 2375 /** 2376 * Delete the upload task 2377 * 2378 * @permission ohos.permission.INTERNET 2379 * @param { AsyncCallback<boolean> } callback 2380 * @throws { BusinessError } 201 - the permissions check fails 2381 * @throws { BusinessError } 401 - the parameters check fails 2382 * @syscap SystemCapability.MiscServices.Upload 2383 * @crossplatform 2384 * @since 10 2385 */ 2386 /** 2387 * Delete the upload task 2388 * 2389 * @permission ohos.permission.INTERNET 2390 * @param { AsyncCallback<boolean> } callback 2391 * @throws { BusinessError } 201 - the permissions check fails 2392 * @syscap SystemCapability.MiscServices.Upload 2393 * @crossplatform 2394 * @since 12 2395 */ 2396 delete(callback: AsyncCallback<boolean>): void; 2397 2398 /** 2399 * Delete the upload task 2400 * 2401 * @permission ohos.permission.INTERNET 2402 * @returns { Promise<boolean> } the promise returned by the function. 2403 * @throws { BusinessError } 201 - the permissions check fails 2404 * @throws { BusinessError } 401 - the parameters check fails 2405 * @syscap SystemCapability.MiscServices.Upload 2406 * @since 9 2407 */ 2408 /** 2409 * Delete the upload task 2410 * 2411 * @permission ohos.permission.INTERNET 2412 * @returns { Promise<boolean> } the promise returned by the function. 2413 * @throws { BusinessError } 201 - the permissions check fails 2414 * @throws { BusinessError } 401 - the parameters check fails 2415 * @syscap SystemCapability.MiscServices.Upload 2416 * @crossplatform 2417 * @since 10 2418 */ 2419 /** 2420 * Delete the upload task 2421 * 2422 * @permission ohos.permission.INTERNET 2423 * @returns { Promise<boolean> } the promise returned by the function. 2424 * @throws { BusinessError } 201 - the permissions check fails 2425 * @syscap SystemCapability.MiscServices.Upload 2426 * @crossplatform 2427 * @since 12 2428 */ 2429 delete(): Promise<boolean>; 2430 } 2431 2432 /** 2433 * The request agent api. 2434 * Supports "background" and "frontend" tasks as while. 2435 * Though "background" and "frontend" here do not the same with process's concept. 2436 * All tasks will be executed at request manager service and recorded. 2437 * Background tasks is for concurrent transfer, such as caching videos for a later play. 2438 * Frontend tasks is for instant transfer, such as submitting forms for a consumption bill. 2439 * Background tasks use notification to tell user tasks' status information. 2440 * Frontend tasks use callback to tell caller tasks' status information. 2441 * Background has some automatically restore mechanism. 2442 * Frontend tasks controlled by caller. 2443 * Uses `multipart/form-data` in client request for upload. 2444 * A `Content-Disposition: attachment; filename=<filename>` response from server leads to download. 2445 * More details, please see the architecture documents of the request subsystem. 2446 * 2447 * @namespace agent 2448 * @syscap SystemCapability.Request.FileTransferAgent 2449 * @since 10 2450 */ 2451 /** 2452 * The request agent api. 2453 * Supports "background" and "frontend" tasks as while. 2454 * Though "background" and "frontend" here do not the same with process's concept. 2455 * All tasks will be executed at request manager service and recorded. 2456 * Background tasks is for concurrent transfer, such as caching videos for a later play. 2457 * Frontend tasks is for instant transfer, such as submitting forms for a consumption bill. 2458 * Background tasks use notification to tell user tasks' status information. 2459 * Frontend tasks use callback to tell caller tasks' status information. 2460 * Background has some automatically restore mechanism. 2461 * Frontend tasks controlled by caller. 2462 * Uses `multipart/form-data` in client request for upload. 2463 * A `Content-Disposition: attachment; filename=<filename>` response from server leads to download. 2464 * More details, please see the architecture documents of the request subsystem. 2465 * Only front-end mode is supported in cross-platform scenarios. 2466 * 2467 * @namespace agent 2468 * @syscap SystemCapability.Request.FileTransferAgent 2469 * @crossplatform 2470 * @atomicservice 2471 * @since 11 2472 */ 2473 namespace agent { 2474 /** 2475 * The action options. 2476 * 2477 * @enum { number } Action 2478 * @syscap SystemCapability.Request.FileTransferAgent 2479 * @since 10 2480 */ 2481 /** 2482 * The action options. 2483 * 2484 * @enum { number } Action 2485 * @syscap SystemCapability.Request.FileTransferAgent 2486 * @crossplatform 2487 * @atomicservice 2488 * @since 11 2489 */ 2490 enum Action { 2491 /** 2492 * Indicates download task. 2493 * 2494 * @syscap SystemCapability.Request.FileTransferAgent 2495 * @since 10 2496 */ 2497 /** 2498 * Indicates download task. 2499 * 2500 * @syscap SystemCapability.Request.FileTransferAgent 2501 * @crossplatform 2502 * @atomicservice 2503 * @since 11 2504 */ 2505 DOWNLOAD, 2506 /** 2507 * Indicates upload task. 2508 * 2509 * @syscap SystemCapability.Request.FileTransferAgent 2510 * @since 10 2511 */ 2512 /** 2513 * Indicates upload task. 2514 * 2515 * @syscap SystemCapability.Request.FileTransferAgent 2516 * @crossplatform 2517 * @atomicservice 2518 * @since 11 2519 */ 2520 UPLOAD 2521 } 2522 2523 /** 2524 * The mode options. 2525 * 2526 * @enum { number } Mode 2527 * @syscap SystemCapability.Request.FileTransferAgent 2528 * @since 10 2529 */ 2530 /** 2531 * The mode options. 2532 * 2533 * @enum { number } Mode 2534 * @syscap SystemCapability.Request.FileTransferAgent 2535 * @crossplatform 2536 * @atomicservice 2537 * @since 11 2538 */ 2539 enum Mode { 2540 /** 2541 * Indicates background task. 2542 * 2543 * @syscap SystemCapability.Request.FileTransferAgent 2544 * @since 10 2545 */ 2546 /** 2547 * Indicates background task. 2548 * 2549 * @syscap SystemCapability.Request.FileTransferAgent 2550 * @atomicservice 2551 * @since 11 2552 */ 2553 BACKGROUND, 2554 /** 2555 * Indicates foreground task. 2556 * 2557 * @syscap SystemCapability.Request.FileTransferAgent 2558 * @since 10 2559 */ 2560 /** 2561 * Indicates foreground task. 2562 * 2563 * @syscap SystemCapability.Request.FileTransferAgent 2564 * @crossplatform 2565 * @atomicservice 2566 * @since 11 2567 */ 2568 FOREGROUND 2569 } 2570 2571 /** 2572 * The network options. 2573 * 2574 * @enum { number } Network 2575 * @syscap SystemCapability.Request.FileTransferAgent 2576 * @since 10 2577 */ 2578 /** 2579 * The network options. 2580 * 2581 * @enum { number } Network 2582 * @syscap SystemCapability.Request.FileTransferAgent 2583 * @crossplatform 2584 * @atomicservice 2585 * @since 11 2586 */ 2587 enum Network { 2588 /** 2589 * Indicates no restriction on network type. 2590 * 2591 * @syscap SystemCapability.Request.FileTransferAgent 2592 * @since 10 2593 */ 2594 /** 2595 * Indicates no restriction on network type. 2596 * 2597 * @syscap SystemCapability.Request.FileTransferAgent 2598 * @crossplatform 2599 * @atomicservice 2600 * @since 11 2601 */ 2602 ANY, 2603 /** 2604 * Indicates Wi-Fi only. 2605 * 2606 * @syscap SystemCapability.Request.FileTransferAgent 2607 * @since 10 2608 */ 2609 /** 2610 * Indicates Wi-Fi only. 2611 * 2612 * @syscap SystemCapability.Request.FileTransferAgent 2613 * @crossplatform 2614 * @atomicservice 2615 * @since 11 2616 */ 2617 WIFI, 2618 /** 2619 * Indicates cellular only. 2620 * 2621 * @syscap SystemCapability.Request.FileTransferAgent 2622 * @since 10 2623 */ 2624 /** 2625 * Indicates cellular only. 2626 * 2627 * @syscap SystemCapability.Request.FileTransferAgent 2628 * @crossplatform 2629 * @atomicservice 2630 * @since 11 2631 */ 2632 CELLULAR 2633 } 2634 2635 /** 2636 * Broadcast events for the request. 2637 * 2638 * @enum { string } BroadcastEvent 2639 * @syscap SystemCapability.Request.FileTransferAgent 2640 * @since 11 2641 */ 2642 enum BroadcastEvent { 2643 /** 2644 * Completion event for the task. 2645 * The code in the commonEventData can only be "0x40"(COMPLETE) or "0x41"(FAILED), same as "State". 2646 * The data in the commonEventData contains the id of the task. 2647 * 2648 * @syscap SystemCapability.Request.FileTransferAgent 2649 * @since 11 2650 */ 2651 COMPLETE = 'ohos.request.event.COMPLETE' 2652 } 2653 2654 /** 2655 * The file information for a form item. 2656 * 2657 * @typedef FileSpec 2658 * @syscap SystemCapability.Request.FileTransferAgent 2659 * @since 10 2660 */ 2661 /** 2662 * The file information for a form item. 2663 * 2664 * @typedef FileSpec 2665 * @syscap SystemCapability.Request.FileTransferAgent 2666 * @crossplatform 2667 * @atomicservice 2668 * @since 11 2669 */ 2670 interface FileSpec { 2671 /** 2672 * A relative path string, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", in the caller's cache directory. 2673 * 2674 * @type { string } 2675 * @syscap SystemCapability.Request.FileTransferAgent 2676 * @since 10 2677 */ 2678 /** 2679 * A relative path string, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", in the caller's cache directory. 2680 * 2681 * @type { string } 2682 * @syscap SystemCapability.Request.FileTransferAgent 2683 * @crossplatform 2684 * @atomicservice 2685 * @since 11 2686 */ 2687 /** 2688 * The path to save the uploaded file. 2689 * Currently support: 2690 * 1: relative path, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", under caller's cache folder. 2691 * 2: internal protocol path, starting with "internal://", like "internal://cache/path/to/file.txt". 2692 * 3: application storage path, only the base directory and its subdirectories are supported, like "/data/storage/el1/base/path/to/file.txt". 2693 * 4: file protocol path with self bundle name, only the base directory and its subdirectories are supported, like "file://com.example.test/data/storage/el2/base/file.txt". 2694 * 5: user file url, like "file://media/Photo/path/to/file.png". 2695 * 2696 * @type { string } 2697 * @syscap SystemCapability.Request.FileTransferAgent 2698 * @crossplatform 2699 * @atomicservice 2700 * @since 12 2701 */ 2702 path: string; 2703 /** 2704 * The MIME type of the file. 2705 * The default is obtained by the suffix of the filename. 2706 * 2707 * @type { ?string } 2708 * @syscap SystemCapability.Request.FileTransferAgent 2709 * @since 10 2710 */ 2711 /** 2712 * The MIME type of the file. 2713 * The default is obtained by the suffix of the filename. 2714 * 2715 * @type { ?string } 2716 * @syscap SystemCapability.Request.FileTransferAgent 2717 * @crossplatform 2718 * @atomicservice 2719 * @since 11 2720 */ 2721 mimeType?: string; 2722 /** 2723 * The filename, the default is obtained by path. 2724 * 2725 * @type { ?string } 2726 * @syscap SystemCapability.Request.FileTransferAgent 2727 * @since 10 2728 */ 2729 /** 2730 * The filename, the default is obtained by path. 2731 * 2732 * @type { ?string } 2733 * @syscap SystemCapability.Request.FileTransferAgent 2734 * @crossplatform 2735 * @atomicservice 2736 * @since 11 2737 */ 2738 filename?: string; 2739 /** 2740 * The extras for the file information. 2741 * 2742 * @type { ?object } 2743 * @syscap SystemCapability.Request.FileTransferAgent 2744 * @since 10 2745 */ 2746 /** 2747 * The extras for the file information. 2748 * 2749 * @type { ?object } 2750 * @syscap SystemCapability.Request.FileTransferAgent 2751 * @crossplatform 2752 * @atomicservice 2753 * @since 11 2754 */ 2755 extras?: object; 2756 } 2757 2758 /** 2759 * The form item information for a task. 2760 * 2761 * @typedef FormItem 2762 * @syscap SystemCapability.Request.FileTransferAgent 2763 * @since 10 2764 */ 2765 /** 2766 * The form item information for a task. 2767 * 2768 * @typedef FormItem 2769 * @syscap SystemCapability.Request.FileTransferAgent 2770 * @crossplatform 2771 * @atomicservice 2772 * @since 11 2773 */ 2774 interface FormItem { 2775 /** 2776 * The item's name. 2777 * 2778 * @type { string } 2779 * @syscap SystemCapability.Request.FileTransferAgent 2780 * @since 10 2781 */ 2782 /** 2783 * The item's name. 2784 * 2785 * @type { string } 2786 * @syscap SystemCapability.Request.FileTransferAgent 2787 * @crossplatform 2788 * @atomicservice 2789 * @since 11 2790 */ 2791 name: string; 2792 /** 2793 * The item's value. 2794 * 2795 * @type { string | FileSpec | Array<FileSpec> } 2796 * @syscap SystemCapability.Request.FileTransferAgent 2797 * @since 10 2798 */ 2799 /** 2800 * The item's value. 2801 * 2802 * @type { string | FileSpec | Array<FileSpec> } 2803 * @syscap SystemCapability.Request.FileTransferAgent 2804 * @crossplatform 2805 * @atomicservice 2806 * @since 11 2807 */ 2808 value: string | FileSpec | Array<FileSpec>; 2809 } 2810 2811 /** 2812 * The configurations for a task. 2813 * Using a flexible configuration for clear upload and download functions. 2814 * If without emphasis, an option is for any task. 2815 * 2816 * @typedef Config 2817 * @syscap SystemCapability.Request.FileTransferAgent 2818 * @since 10 2819 */ 2820 /** 2821 * The configurations for a task. 2822 * Using a flexible configuration for clear upload and download functions. 2823 * If without emphasis, an option is for any task. 2824 * 2825 * @typedef Config 2826 * @syscap SystemCapability.Request.FileTransferAgent 2827 * @crossplatform 2828 * @atomicservice 2829 * @since 11 2830 */ 2831 interface Config { 2832 /** 2833 * The task action, upload or download. 2834 * 2835 * @type { Action } 2836 * @syscap SystemCapability.Request.FileTransferAgent 2837 * @since 10 2838 */ 2839 /** 2840 * The task action, upload or download. 2841 * 2842 * @type { Action } 2843 * @syscap SystemCapability.Request.FileTransferAgent 2844 * @crossplatform 2845 * @atomicservice 2846 * @since 11 2847 */ 2848 action: Action; 2849 /** 2850 * The Universal Resource Locator for a task. 2851 * Starting with http(s):// 2852 * The maximum length is 2048 characters. 2853 * Using raw `url` option, even url parameters in it. 2854 * 2855 * @type { string } 2856 * @syscap SystemCapability.Request.FileTransferAgent 2857 * @since 10 2858 */ 2859 /** 2860 * The Universal Resource Locator for a task. 2861 * The maximum length is 2048 characters. 2862 * Using raw `url` option, even url parameters in it. 2863 * 2864 * @type { string } 2865 * @syscap SystemCapability.Request.FileTransferAgent 2866 * @crossplatform 2867 * @atomicservice 2868 * @since 11 2869 */ 2870 url: string; 2871 /** 2872 * The title for a task, give a meaningful title please. 2873 * The maximum length is 256 characters. 2874 * The default is the same with its action. 2875 * 2876 * @type { ?string } 2877 * @syscap SystemCapability.Request.FileTransferAgent 2878 * @since 10 2879 */ 2880 /** 2881 * The title for a task, give a meaningful title please. 2882 * The maximum length is 256 characters. 2883 * The default is upload or download, consistent with its action. 2884 * 2885 * @type { ?string } 2886 * @syscap SystemCapability.Request.FileTransferAgent 2887 * @crossplatform 2888 * @atomicservice 2889 * @since 11 2890 */ 2891 title?: string; 2892 /** 2893 * The details for a task. 2894 * The maximum length is 1024 characters. 2895 * The default is empty string. 2896 * 2897 * @type { ?string } 2898 * @syscap SystemCapability.Request.FileTransferAgent 2899 * @since 10 2900 */ 2901 /** 2902 * The details for a task. 2903 * The maximum length is 1024 characters. 2904 * The default is empty string. 2905 * 2906 * @type { ?string } 2907 * @syscap SystemCapability.Request.FileTransferAgent 2908 * @crossplatform 2909 * @atomicservice 2910 * @since 11 2911 */ 2912 description?: string; 2913 /** 2914 * Indicates task's mode. 2915 * The default is background. 2916 * For frontend task, it has callbacks. 2917 * For background task, it has notifications and fallback. 2918 * 2919 * @type { ?Mode } 2920 * @syscap SystemCapability.Request.FileTransferAgent 2921 * @since 10 2922 */ 2923 /** 2924 * Indicates task's mode. 2925 * The default is BACKGROUND. 2926 * For frontend task, it has callbacks. 2927 * For background task, it has notifications and fallback. 2928 * The cross-platform default is FOREGROUND. 2929 * 2930 * @type { ?Mode } 2931 * @syscap SystemCapability.Request.FileTransferAgent 2932 * @crossplatform 2933 * @atomicservice 2934 * @since 11 2935 */ 2936 2937 mode?: Mode; 2938 /** 2939 * The solution choice when path already exists during download. 2940 * Currently support: 2941 * true, rewrite the existed file. 2942 * false, go to fail. 2943 * 2944 * @type { ?boolean } 2945 * @syscap SystemCapability.Request.FileTransferAgent 2946 * @since 10 2947 */ 2948 /** 2949 * The solution choice when path already exists during download. 2950 * The default is false. 2951 * Currently support: 2952 * true, rewrite the existed file. 2953 * false, go to fail. 2954 * 2955 * @type { ?boolean } 2956 * @syscap SystemCapability.Request.FileTransferAgent 2957 * @crossplatform 2958 * @atomicservice 2959 * @since 11 2960 */ 2961 overwrite?: boolean; 2962 /** 2963 * The HTTP standard method for upload or download: GET/POST/PUT. 2964 * Case insensitive. 2965 * For upload, use PUT/POST, the default is PUT. 2966 * For download, use GET/POST, the default is GET. 2967 * 2968 * @type { ?string } 2969 * @syscap SystemCapability.Request.FileTransferAgent 2970 * @since 10 2971 */ 2972 /** 2973 * The HTTP standard method for upload or download: GET/POST/PUT. 2974 * Case insensitive. 2975 * For upload, use PUT/POST, the default is PUT. 2976 * For download, use GET/POST, the default is GET. 2977 * 2978 * @type { ?string } 2979 * @syscap SystemCapability.Request.FileTransferAgent 2980 * @crossplatform 2981 * @atomicservice 2982 * @since 11 2983 */ 2984 method?: string; 2985 /** 2986 * The HTTP headers. 2987 * For upload request, the `Content-Type` is forced to `multipart/form-data`. 2988 * For download request, the default `Content-Type` is `application/json`. 2989 * 2990 * @type { ?object } 2991 * @syscap SystemCapability.Request.FileTransferAgent 2992 * @since 10 2993 */ 2994 /** 2995 * The HTTP headers. 2996 * For upload request, the `Content-Type` is forced to `multipart/form-data`. 2997 * For download request, the default `Content-Type` is `application/json`. 2998 * 2999 * @type { ?object } 3000 * @syscap SystemCapability.Request.FileTransferAgent 3001 * @crossplatform 3002 * @atomicservice 3003 * @since 11 3004 */ 3005 headers?: object; 3006 /** 3007 * The arguments, it can be any text, uses json usually. 3008 * For download, it can be raw string, the default is empty string. 3009 * For upload, it can be form items, the default is a empty form. 3010 * there must be one `FileSpec` item at least or will be a parameter error. 3011 * 3012 * @type { ?(string | Array<FormItem>) } 3013 * @syscap SystemCapability.Request.FileTransferAgent 3014 * @since 10 3015 */ 3016 /** 3017 * The arguments, it can be any text, uses json usually. 3018 * For download, it can be raw string, the default is empty string. 3019 * For upload, it can be form items, the default is a empty form. 3020 * there must be one `FileSpec` item at least or will be a parameter error. 3021 * 3022 * @type { ?(string | Array<FormItem>) } 3023 * @syscap SystemCapability.Request.FileTransferAgent 3024 * @crossplatform 3025 * @atomicservice 3026 * @since 11 3027 */ 3028 data?: string | Array<FormItem>; 3029 /** 3030 * The path to save the downloaded file, the default is "./". 3031 * Currently support: 3032 * 1: relative path, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", under caller's cache folder. 3033 * 2: uri path, like "datashare://bundle/xxx/yyy/zzz.html", the data provider must allow the caller's access. 3034 * 3035 * @type { ?string } 3036 * @default ./ 3037 * @syscap SystemCapability.Request.FileTransferAgent 3038 * @since 10 3039 */ 3040 /** 3041 * The path to save the downloaded file, the default is "./". 3042 * Currently support: 3043 * 1: relative path, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", under caller's cache folder. 3044 * 2: uri path, like "datashare://bundle/xxx/yyy/zzz.html", the data provider must allow the caller's access. 3045 * 3046 * @type { ?string } 3047 * @default ./ 3048 * @syscap SystemCapability.Request.FileTransferAgent 3049 * @crossplatform 3050 * @atomicservice 3051 * @since 11 3052 */ 3053 /** 3054 * The path to save the downloaded file, the default is "./". 3055 * Currently support: 3056 * 1: relative path, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", under caller's cache folder. 3057 * 2: internal protocol path, starting with "internal://", like "internal://cache/path/to/file.txt". 3058 * 3: application storage path, only the base directory and its subdirectories are supported, like "/data/storage/el1/base/path/to/file.txt". 3059 * 4: file protocol path with self bundle name, only the base directory and its subdirectories are supported, like "file://com.example.test/data/storage/el2/base/file.txt". 3060 * 3061 * @type { ?string } 3062 * @default ./ 3063 * @syscap SystemCapability.Request.FileTransferAgent 3064 * @crossplatform 3065 * @atomicservice 3066 * @since 12 3067 */ 3068 saveas?: string; 3069 /** 3070 * The network. 3071 * 3072 * @type { ?Network } 3073 * @default Network.ANY 3074 * @syscap SystemCapability.Request.FileTransferAgent 3075 * @since 10 3076 */ 3077 /** 3078 * The network. 3079 * 3080 * @type { ?Network } 3081 * @default Network.ANY 3082 * @syscap SystemCapability.Request.FileTransferAgent 3083 * @crossplatform 3084 * @atomicservice 3085 * @since 11 3086 */ 3087 network?: Network; 3088 /** 3089 * Allows work in metered network or not. 3090 * The default is false. 3091 * 3092 * @type { ?boolean } 3093 * @default false 3094 * @syscap SystemCapability.Request.FileTransferAgent 3095 * @since 10 3096 */ 3097 /** 3098 * Allows work in metered network or not. 3099 * The default is false. 3100 * 3101 * @type { ?boolean } 3102 * @default false 3103 * @syscap SystemCapability.Request.FileTransferAgent 3104 * @crossplatform 3105 * @atomicservice 3106 * @since 11 3107 */ 3108 metered?: boolean; 3109 /** 3110 * Allows work in roaming network or not. 3111 * The default is true. 3112 * 3113 * @type { ?boolean } 3114 * @syscap SystemCapability.Request.FileTransferAgent 3115 * @since 10 3116 */ 3117 /** 3118 * Allows work in roaming network or not. 3119 * The default is true. 3120 * 3121 * @type { ?boolean } 3122 * @syscap SystemCapability.Request.FileTransferAgent 3123 * @crossplatform 3124 * @atomicservice 3125 * @since 11 3126 */ 3127 roaming?: boolean; 3128 /** 3129 * Enable automatic retry or not for the background task. 3130 * The frontend task is always fast-fail. 3131 * 3132 * @type { ?boolean } 3133 * @syscap SystemCapability.Request.FileTransferAgent 3134 * @since 10 3135 */ 3136 /** 3137 * Enable automatic retry or not for the background task. 3138 * The frontend task is always fast-fail. 3139 * 3140 * @type { ?boolean } 3141 * @syscap SystemCapability.Request.FileTransferAgent 3142 * @atomicservice 3143 * @since 11 3144 */ 3145 retry?: boolean; 3146 /** 3147 * Allows redirect or not. 3148 * The default is yes. 3149 * 3150 * @type { ?boolean } 3151 * @syscap SystemCapability.Request.FileTransferAgent 3152 * @since 10 3153 */ 3154 /** 3155 * Allows redirect or not. 3156 * The default is true. 3157 * 3158 * @type { ?boolean } 3159 * @syscap SystemCapability.Request.FileTransferAgent 3160 * @crossplatform 3161 * @atomicservice 3162 * @since 11 3163 */ 3164 redirect?: boolean; 3165 /** 3166 * The proxy url for the task. 3167 * Only this format is supported: http://<domain or IP-address>:<port> 3168 * Username and password are not supported. 3169 * 3170 * @type { ?string } 3171 * @syscap SystemCapability.Request.FileTransferAgent 3172 * @since 12 3173 */ 3174 proxy?: string; 3175 /** 3176 * The index of paths for a task. 3177 * Usually used for a continuous job. 3178 * The default is 0. 3179 * 3180 * @type { ?number } 3181 * @syscap SystemCapability.Request.FileTransferAgent 3182 * @since 10 3183 */ 3184 /** 3185 * The index of paths for a task. 3186 * Usually used for a continuous job. 3187 * The default is 0. 3188 * 3189 * @type { ?number } 3190 * @syscap SystemCapability.Request.FileTransferAgent 3191 * @crossplatform 3192 * @atomicservice 3193 * @since 11 3194 */ 3195 index?: number; 3196 /** 3197 * The start point of a file. 3198 * Usually used for a continuous job. 3199 * It will set the "Range" header in download. 3200 * It will start read at the point in upload. 3201 * The default is 0. 3202 * 3203 * @type { ?number } 3204 * @syscap SystemCapability.Request.FileTransferAgent 3205 * @since 10 3206 */ 3207 /** 3208 * The start point of a file. 3209 * Usually used for a continuous job. 3210 * It will set the "Range" header in download. 3211 * It will start read at the point in upload. 3212 * The default is 0. 3213 * 3214 * @type { ?number } 3215 * @syscap SystemCapability.Request.FileTransferAgent 3216 * @crossplatform 3217 * @atomicservice 3218 * @since 11 3219 */ 3220 begins?: number; 3221 /** 3222 * The end point of a file. 3223 * Usually used for a continuous job. 3224 * It will set The "Range" header in download. 3225 * It will end read at the point in upload. 3226 * The default is -1 indicating the end of the data for upload or download. 3227 * 3228 * @type { ?number } 3229 * @syscap SystemCapability.Request.FileTransferAgent 3230 * @since 10 3231 */ 3232 /** 3233 * The end point of a file. 3234 * Usually used for a continuous job. 3235 * It will set The "Range" header in download. 3236 * It will end read at the point in upload. 3237 * The default is -1 indicating the end of the data for upload or download. 3238 * 3239 * @type { ?number } 3240 * @syscap SystemCapability.Request.FileTransferAgent 3241 * @crossplatform 3242 * @atomicservice 3243 * @since 11 3244 */ 3245 ends?: number; 3246 /** 3247 * The policy of the progress notification for background task. 3248 * If false: only completed or failed notification, the default. 3249 * If true, emits every progress, completed or failed notifications. 3250 * 3251 * @type { ?boolean } 3252 * @syscap SystemCapability.Request.FileTransferAgent 3253 * @since 10 3254 */ 3255 /** 3256 * The policy of the progress notification for background task. 3257 * If false: only completed or failed notification, the default. 3258 * If true, emits every progress, completed or failed notifications. 3259 * 3260 * @type { ?boolean } 3261 * @syscap SystemCapability.Request.FileTransferAgent 3262 * @atomicservice 3263 * @since 11 3264 */ 3265 gauge?: boolean; 3266 /** 3267 * Breaks when fail to fetch filesize before upload/download or not. 3268 * Uses filesize for a precise gauge. 3269 * The default is not, set size as -1 indicating the case. 3270 * 3271 * @type { ?boolean } 3272 * @syscap SystemCapability.Request.FileTransferAgent 3273 * @since 10 3274 */ 3275 /** 3276 * Breaks when fail to fetch filesize before upload/download or not. 3277 * Uses filesize for a precise gauge. 3278 * The default is false, set size as -1 indicating the case. 3279 * 3280 * @type { ?boolean } 3281 * @syscap SystemCapability.Request.FileTransferAgent 3282 * @crossplatform 3283 * @atomicservice 3284 * @since 11 3285 */ 3286 precise?: boolean; 3287 /** 3288 * For in-application layer isolation. 3289 * If given: 3290 * the minimum is 8 bytes. 3291 * the maximum is 2048 bytes. 3292 * Creates a task with token, then must provide it during normal query. 3293 * So saves the token carefully, it can not be retrieved by query. 3294 * Or leave it empty. 3295 * 3296 * @type { ?string } 3297 * @syscap SystemCapability.Request.FileTransferAgent 3298 * @since 10 3299 */ 3300 /** 3301 * For in-application layer isolation. 3302 * If given: 3303 * the minimum is 8 bytes. 3304 * the maximum is 2048 bytes. 3305 * Creates a task with token, then must provide it during normal query. 3306 * So saves the token carefully, it can not be retrieved by query. 3307 * Or leave it empty. 3308 * 3309 * @type { ?string } 3310 * @syscap SystemCapability.Request.FileTransferAgent 3311 * @crossplatform 3312 * @atomicservice 3313 * @since 11 3314 */ 3315 token?: string; 3316 /** 3317 * The priority of this task. 3318 * Front-end tasks have higher priority than back-end tasks. 3319 * In tasks of the same mode, the smaller the number, the higher the priority. 3320 * The default is 0. 3321 * 3322 * @type { ?number } 3323 * @syscap SystemCapability.Request.FileTransferAgent 3324 * @since 11 3325 */ 3326 priority?: number; 3327 /** 3328 * The extras for the configuration. 3329 * 3330 * @type { ?object } 3331 * @syscap SystemCapability.Request.FileTransferAgent 3332 * @since 10 3333 */ 3334 /** 3335 * The extras for the configuration. 3336 * 3337 * @type { ?object } 3338 * @syscap SystemCapability.Request.FileTransferAgent 3339 * @crossplatform 3340 * @atomicservice 3341 * @since 11 3342 */ 3343 extras?: object; 3344 } 3345 3346 /** 3347 * Indicate the current state of the task. 3348 * 3349 * @enum { number } State 3350 * @syscap SystemCapability.Request.FileTransferAgent 3351 * @since 10 3352 */ 3353 /** 3354 * Indicate the current state of the task. 3355 * 3356 * @enum { number } State 3357 * @syscap SystemCapability.Request.FileTransferAgent 3358 * @crossplatform 3359 * @atomicservice 3360 * @since 11 3361 */ 3362 enum State { 3363 /** 3364 * Indicates a task created by `new Task(Config)`. 3365 * 3366 * @syscap SystemCapability.Request.FileTransferAgent 3367 * @since 10 3368 */ 3369 /** 3370 * Indicates a task created by `new Task(Config)`. 3371 * 3372 * @syscap SystemCapability.Request.FileTransferAgent 3373 * @crossplatform 3374 * @atomicservice 3375 * @since 11 3376 */ 3377 INITIALIZED = 0x00, 3378 /** 3379 * Indicates a task lack of resources or conditions to run or retry. 3380 * 3381 * @syscap SystemCapability.Request.FileTransferAgent 3382 * @since 10 3383 */ 3384 /** 3385 * Indicates a task lack of resources or conditions to run or retry. 3386 * 3387 * @syscap SystemCapability.Request.FileTransferAgent 3388 * @crossplatform 3389 * @atomicservice 3390 * @since 11 3391 */ 3392 WAITING = 0x10, 3393 /** 3394 * Indicates a task in processing now. 3395 * 3396 * @syscap SystemCapability.Request.FileTransferAgent 3397 * @since 10 3398 */ 3399 /** 3400 * Indicates a task in processing now. 3401 * 3402 * @syscap SystemCapability.Request.FileTransferAgent 3403 * @crossplatform 3404 * @atomicservice 3405 * @since 11 3406 */ 3407 RUNNING = 0x20, 3408 /** 3409 * Indicates a task failed once at least and in processing again now. 3410 * 3411 * @syscap SystemCapability.Request.FileTransferAgent 3412 * @since 10 3413 */ 3414 /** 3415 * Indicates a task failed once at least and in processing again now. 3416 * 3417 * @syscap SystemCapability.Request.FileTransferAgent 3418 * @crossplatform 3419 * @atomicservice 3420 * @since 11 3421 */ 3422 RETRYING = 0x21, 3423 /** 3424 * Indicates a paused task which tends to be resumed for continuous work. 3425 * 3426 * @syscap SystemCapability.Request.FileTransferAgent 3427 * @since 10 3428 */ 3429 /** 3430 * Indicates a paused task which tends to be resumed for continuous work. 3431 * 3432 * @syscap SystemCapability.Request.FileTransferAgent 3433 * @crossplatform 3434 * @atomicservice 3435 * @since 11 3436 */ 3437 PAUSED = 0x30, 3438 /** 3439 * Indicates a stopped task which must be started again. 3440 * 3441 * @syscap SystemCapability.Request.FileTransferAgent 3442 * @since 10 3443 */ 3444 /** 3445 * Indicates a stopped task which must be started again. 3446 * 3447 * @syscap SystemCapability.Request.FileTransferAgent 3448 * @crossplatform 3449 * @atomicservice 3450 * @since 11 3451 */ 3452 STOPPED = 0x31, 3453 /** 3454 * Indicates a completed task which finish its data transfer. 3455 * 3456 * @syscap SystemCapability.Request.FileTransferAgent 3457 * @since 10 3458 */ 3459 /** 3460 * Indicates a completed task which finish its data transfer. 3461 * 3462 * @syscap SystemCapability.Request.FileTransferAgent 3463 * @crossplatform 3464 * @atomicservice 3465 * @since 11 3466 */ 3467 COMPLETED = 0x40, 3468 /** 3469 * Indicates a failed task which interrupted by some error. 3470 * 3471 * @syscap SystemCapability.Request.FileTransferAgent 3472 * @since 10 3473 */ 3474 /** 3475 * Indicates a failed task which interrupted by some error. 3476 * 3477 * @syscap SystemCapability.Request.FileTransferAgent 3478 * @crossplatform 3479 * @atomicservice 3480 * @since 11 3481 */ 3482 FAILED = 0x41, 3483 /** 3484 * Indicates a removed task which can not be processed again. 3485 * 3486 * @syscap SystemCapability.Request.FileTransferAgent 3487 * @since 10 3488 */ 3489 /** 3490 * Indicates a removed task which can not be processed again. 3491 * 3492 * @syscap SystemCapability.Request.FileTransferAgent 3493 * @crossplatform 3494 * @atomicservice 3495 * @since 11 3496 */ 3497 REMOVED = 0x50 3498 } 3499 3500 /** 3501 * The progress data structure. 3502 * Upload allows multiple files per upload task. 3503 * Only one file in a download task. 3504 * So using a unified data structure for progress. 3505 * Generally: 3506 * 1: sum(sizes) is total files size of the task. 3507 * 2: float(processed)/sizes[counter] is the progress for the current processing file. 3508 * 3: float(sum(sizes[:index])+processed)/sum(sizes) is the summary progress for a task. 3509 * If fetch file size in failure, the size of the file in sizes will be set as -1. 3510 * 3511 * @typedef Progress 3512 * @syscap SystemCapability.Request.FileTransferAgent 3513 * @since 10 3514 */ 3515 /** 3516 * The progress data structure. 3517 * Upload allows multiple files per upload task. 3518 * Only one file in a download task. 3519 * So using a unified data structure for progress. 3520 * Generally: 3521 * 1: sum(sizes) is total files size of the task. 3522 * 2: float(processed)/sizes[counter] is the progress for the current processing file. 3523 * 3: float(sum(sizes[:index])+processed)/sum(sizes) is the summary progress for a task. 3524 * If fetch file size in failure, the size of the file in sizes will be set as -1. 3525 * 3526 * @typedef Progress 3527 * @syscap SystemCapability.Request.FileTransferAgent 3528 * @crossplatform 3529 * @atomicservice 3530 * @since 11 3531 */ 3532 interface Progress { 3533 /** 3534 * The current state of the task. 3535 * 3536 * @type { State } 3537 * @readonly 3538 * @syscap SystemCapability.Request.FileTransferAgent 3539 * @since 10 3540 */ 3541 /** 3542 * The current state of the task. 3543 * 3544 * @type { State } 3545 * @readonly 3546 * @syscap SystemCapability.Request.FileTransferAgent 3547 * @crossplatform 3548 * @atomicservice 3549 * @since 11 3550 */ 3551 readonly state: State; 3552 /** 3553 * The current processing file index in a task. 3554 * 3555 * @type { number } 3556 * @readonly 3557 * @syscap SystemCapability.Request.FileTransferAgent 3558 * @since 10 3559 */ 3560 /** 3561 * The current processing file index in a task. 3562 * 3563 * @type { number } 3564 * @readonly 3565 * @syscap SystemCapability.Request.FileTransferAgent 3566 * @crossplatform 3567 * @atomicservice 3568 * @since 11 3569 */ 3570 readonly index: number; 3571 /** 3572 * The processed data size for the current file in a task. 3573 * 3574 * @type { number } 3575 * @readonly 3576 * @syscap SystemCapability.Request.FileTransferAgent 3577 * @since 10 3578 */ 3579 /** 3580 * The processed data size for the current file in a task. 3581 * 3582 * @type { number } 3583 * @readonly 3584 * @syscap SystemCapability.Request.FileTransferAgent 3585 * @crossplatform 3586 * @atomicservice 3587 * @since 11 3588 */ 3589 readonly processed: number; 3590 /** 3591 * The sizes of files in a task. 3592 * 3593 * @type { Array<number> } 3594 * @readonly 3595 * @syscap SystemCapability.Request.FileTransferAgent 3596 * @since 10 3597 */ 3598 /** 3599 * The sizes of files in a task. 3600 * 3601 * @type { Array<number> } 3602 * @readonly 3603 * @syscap SystemCapability.Request.FileTransferAgent 3604 * @crossplatform 3605 * @atomicservice 3606 * @since 11 3607 */ 3608 readonly sizes: Array<number>; 3609 /** 3610 * The extras for an interaction. 3611 * Such as headers and body of response from server. 3612 * But when the Content-Disposition header responded, the body will be into the uri of its attachment only, the body here is empty. 3613 * {"headers": {"key": v}, "body": "contents"}. 3614 * 3615 * @type { ?object } 3616 * @readonly 3617 * @syscap SystemCapability.Request.FileTransferAgent 3618 * @since 10 3619 */ 3620 /** 3621 * The extras for an interaction. 3622 * Such as headers and body of response from server. 3623 * But when the Content-Disposition header responded, the body will be into the uri of its attachment only, the body here is empty. 3624 * {"headers": {"key": v}, "body": "contents"}. 3625 * The "body" field is not supported in cross-platform scenarios. 3626 * 3627 * @type { ?object } 3628 * @readonly 3629 * @syscap SystemCapability.Request.FileTransferAgent 3630 * @crossplatform 3631 * @atomicservice 3632 * @since 11 3633 */ 3634 readonly extras?: object; 3635 } 3636 3637 /** 3638 * Indicates the reason for the failure. 3639 * 3640 * @enum { number } 3641 * @syscap SystemCapability.Request.FileTransferAgent 3642 * @since 10 3643 */ 3644 /** 3645 * Indicates the reason for the failure. 3646 * 3647 * @enum { number } 3648 * @syscap SystemCapability.Request.FileTransferAgent 3649 * @crossplatform 3650 * @atomicservice 3651 * @since 11 3652 */ 3653 enum Faults { 3654 /** 3655 * Indicates others failure. 3656 * 3657 * @syscap SystemCapability.Request.FileTransferAgent 3658 * @since 10 3659 */ 3660 /** 3661 * Indicates others failure. 3662 * 3663 * @syscap SystemCapability.Request.FileTransferAgent 3664 * @crossplatform 3665 * @atomicservice 3666 * @since 11 3667 */ 3668 OTHERS = 0xFF, 3669 /** 3670 * Indicates network disconnection. 3671 * 3672 * @syscap SystemCapability.Request.FileTransferAgent 3673 * @since 10 3674 */ 3675 /** 3676 * Indicates network disconnection. 3677 * 3678 * @syscap SystemCapability.Request.FileTransferAgent 3679 * @crossplatform 3680 * @atomicservice 3681 * @since 11 3682 */ 3683 DISCONNECTED = 0x00, 3684 /** 3685 * Indicates task timeout. 3686 * 3687 * @syscap SystemCapability.Request.FileTransferAgent 3688 * @since 10 3689 */ 3690 /** 3691 * Indicates task timeout. 3692 * 3693 * @syscap SystemCapability.Request.FileTransferAgent 3694 * @crossplatform 3695 * @atomicservice 3696 * @since 11 3697 */ 3698 TIMEOUT = 0x10, 3699 /** 3700 * Indicates protocol error, such as 5xx response from server. 3701 * 3702 * @syscap SystemCapability.Request.FileTransferAgent 3703 * @since 10 3704 */ 3705 /** 3706 * Indicates protocol error, such as 5xx response from server. 3707 * 3708 * @syscap SystemCapability.Request.FileTransferAgent 3709 * @crossplatform 3710 * @atomicservice 3711 * @since 11 3712 */ 3713 PROTOCOL = 0x20, 3714 /** 3715 * Indicates parameter error, such as url format error. 3716 * 3717 * @syscap SystemCapability.Request.FileTransferAgent 3718 * @crossplatform 3719 * @atomicservice 3720 * @since 12 3721 */ 3722 PARAM = 0x30, 3723 /** 3724 * Indicates filesystem io error, such as open/seek/read/write/close. 3725 * 3726 * @syscap SystemCapability.Request.FileTransferAgent 3727 * @since 10 3728 */ 3729 /** 3730 * Indicates filesystem io error, such as open/seek/read/write/close. 3731 * 3732 * @syscap SystemCapability.Request.FileTransferAgent 3733 * @crossplatform 3734 * @atomicservice 3735 * @since 11 3736 */ 3737 FSIO = 0x40, 3738 /** 3739 * Indicates DNS resolution error. 3740 * 3741 * @syscap SystemCapability.Request.FileTransferAgent 3742 * @crossplatform 3743 * @atomicservice 3744 * @since 12 3745 */ 3746 DNS = 0x50, 3747 /** 3748 * Indicates TCP connection error. 3749 * 3750 * @syscap SystemCapability.Request.FileTransferAgent 3751 * @crossplatform 3752 * @atomicservice 3753 * @since 12 3754 */ 3755 TCP = 0x60, 3756 /** 3757 * Indicates SSL connection error, such as a certificate error or certificate verification failure. 3758 * 3759 * @syscap SystemCapability.Request.FileTransferAgent 3760 * @crossplatform 3761 * @atomicservice 3762 * @since 12 3763 */ 3764 SSL = 0x70, 3765 /** 3766 * Indicates redirect error. 3767 * 3768 * @syscap SystemCapability.Request.FileTransferAgent 3769 * @crossplatform 3770 * @atomicservice 3771 * @since 12 3772 */ 3773 REDIRECT = 0x80 3774 } 3775 3776 /** 3777 * The filter data structure. 3778 * Used for search, given fields works as **LOGICAL AND**. 3779 * Invalid value may cause a parameter error. 3780 * 3781 * @typedef Filter 3782 * @syscap SystemCapability.Request.FileTransferAgent 3783 * @since 10 3784 */ 3785 /** 3786 * The filter data structure. 3787 * Used for search, given fields works as **LOGICAL AND**. 3788 * Invalid value may cause a parameter error. 3789 * 3790 * @typedef Filter 3791 * @syscap SystemCapability.Request.FileTransferAgent 3792 * @crossplatform 3793 * @since 11 3794 */ 3795 interface Filter { 3796 /** 3797 * Specify the package name of an application. 3798 * Only for advanced search, common search will be fixed to the caller. 3799 * A "*" means any bundle. 3800 * 3801 * @type { ?string } 3802 * @syscap SystemCapability.Request.FileTransferAgent 3803 * @systemapi Hide this for inner system use. 3804 * @since 10 3805 */ 3806 bundle?: string; 3807 /** 3808 * Specify the end Unix timestamp. 3809 * The default is the moment of calling. 3810 * 3811 * @type { ?number } 3812 * @syscap SystemCapability.Request.FileTransferAgent 3813 * @since 10 3814 */ 3815 /** 3816 * Specify the end Unix timestamp. 3817 * The default is the moment of calling. 3818 * 3819 * @type { ?number } 3820 * @syscap SystemCapability.Request.FileTransferAgent 3821 * @crossplatform 3822 * @since 11 3823 */ 3824 before?: number; 3825 /** 3826 * Specify the start Unix timestamp. 3827 * The default is "`before` - 24 hours". 3828 * 3829 * @type { ?number } 3830 * @syscap SystemCapability.Request.FileTransferAgent 3831 * @since 10 3832 */ 3833 /** 3834 * Specify the start Unix timestamp. 3835 * The default is "`before` - 24 hours". 3836 * 3837 * @type { ?number } 3838 * @syscap SystemCapability.Request.FileTransferAgent 3839 * @crossplatform 3840 * @since 11 3841 */ 3842 after?: number; 3843 /** 3844 * Specify the state of tasks. 3845 * The default is any state. 3846 * 3847 * @type { ?State } 3848 * @syscap SystemCapability.Request.FileTransferAgent 3849 * @since 10 3850 */ 3851 /** 3852 * Specify the state of tasks. 3853 * The default is any state. 3854 * 3855 * @type { ?State } 3856 * @syscap SystemCapability.Request.FileTransferAgent 3857 * @crossplatform 3858 * @since 11 3859 */ 3860 state?: State; 3861 /** 3862 * Specify the action of tasks, "upload" or "download", case insensitive. 3863 * The default is upload and download. 3864 * 3865 * @type { ?Action } 3866 * @syscap SystemCapability.Request.FileTransferAgent 3867 * @since 10 3868 */ 3869 /** 3870 * Specify the action of tasks, "upload" or "download", case insensitive. 3871 * The default is upload and download. 3872 * 3873 * @type { ?Action } 3874 * @syscap SystemCapability.Request.FileTransferAgent 3875 * @crossplatform 3876 * @since 11 3877 */ 3878 action?: Action; 3879 /** 3880 * Specify task's mode. 3881 * The default is frontend and background. 3882 * 3883 * @type { ?Mode } 3884 * @syscap SystemCapability.Request.FileTransferAgent 3885 * @since 10 3886 */ 3887 /** 3888 * Specify task's mode. 3889 * The default is FOREGROUND and BACKGROUND. 3890 * 3891 * @type { ?Mode } 3892 * @syscap SystemCapability.Request.FileTransferAgent 3893 * @crossplatform 3894 * @since 11 3895 */ 3896 mode?: Mode; 3897 } 3898 3899 /** 3900 * The task information data structure for query results. 3901 * Provides common query and advanced query, visible range of fields is different. 3902 * 3903 * @typedef TaskInfo 3904 * @syscap SystemCapability.Request.FileTransferAgent 3905 * @since 10 3906 */ 3907 /** 3908 * The task information data structure for query results. 3909 * Provides common query and advanced query, visible range of fields is different. 3910 * 3911 * @typedef TaskInfo 3912 * @syscap SystemCapability.Request.FileTransferAgent 3913 * @crossplatform 3914 * @since 11 3915 */ 3916 interface TaskInfo { 3917 /** 3918 * The UID of an application. 3919 * For system query only. 3920 * 3921 * @type { ?string } 3922 * @readonly 3923 * @syscap SystemCapability.Request.FileTransferAgent 3924 * @systemapi Hide this for inner system use. 3925 * @since 10 3926 */ 3927 readonly uid?: string; 3928 /** 3929 * The bundle name. 3930 * For system query only. 3931 * 3932 * @type { ?string } 3933 * @readonly 3934 * @syscap SystemCapability.Request.FileTransferAgent 3935 * @systemapi Hide this for inner system use. 3936 * @since 10 3937 */ 3938 readonly bundle?: string; 3939 /** 3940 * The path to save the downloaded file. 3941 * 3942 * @type { ?string } 3943 * @syscap SystemCapability.Request.FileTransferAgent 3944 * @since 10 3945 */ 3946 /** 3947 * The path to save the downloaded file. 3948 * 3949 * @type { ?string } 3950 * @readonly 3951 * @syscap SystemCapability.Request.FileTransferAgent 3952 * @crossplatform 3953 * @since 11 3954 */ 3955 readonly saveas?: string; 3956 /** 3957 * The url of a task. 3958 * For `${ show }` and `${ touch }`. 3959 * It is empty string in `${ query }`. 3960 * 3961 * @type { ?string } 3962 * @readonly 3963 * @syscap SystemCapability.Request.FileTransferAgent 3964 * @since 10 3965 */ 3966 /** 3967 * The url of a task. 3968 * For `${ show }` and `${ touch }`. 3969 * 3970 * @type { ?string } 3971 * @readonly 3972 * @syscap SystemCapability.Request.FileTransferAgent 3973 * @crossplatform 3974 * @since 11 3975 */ 3976 readonly url?: string; 3977 /** 3978 * The arguments. 3979 * For `${ show }` and `${ touch }`. 3980 * It is empty string in `${ query }`. 3981 * 3982 * @type { ?(string | Array<FormItem>) } 3983 * @syscap SystemCapability.Request.FileTransferAgent 3984 * @since 10 3985 */ 3986 /** 3987 * The arguments. 3988 * For `${ show }` and `${ touch }`. 3989 * 3990 * @type { ?(string | Array<FormItem>) } 3991 * @readonly 3992 * @syscap SystemCapability.Request.FileTransferAgent 3993 * @crossplatform 3994 * @since 11 3995 */ 3996 readonly data?: string | Array<FormItem>; 3997 /** 3998 * The task id. 3999 * 4000 * @type { string } 4001 * @readonly 4002 * @syscap SystemCapability.Request.FileTransferAgent 4003 * @since 10 4004 */ 4005 /** 4006 * The task id. 4007 * 4008 * @type { string } 4009 * @readonly 4010 * @syscap SystemCapability.Request.FileTransferAgent 4011 * @crossplatform 4012 * @since 11 4013 */ 4014 readonly tid: string; 4015 /** 4016 * The task title. 4017 * 4018 * @type { string } 4019 * @readonly 4020 * @syscap SystemCapability.Request.FileTransferAgent 4021 * @since 10 4022 */ 4023 /** 4024 * The task title. 4025 * 4026 * @type { string } 4027 * @readonly 4028 * @syscap SystemCapability.Request.FileTransferAgent 4029 * @crossplatform 4030 * @since 11 4031 */ 4032 readonly title: string; 4033 /** 4034 * The task details. 4035 * 4036 * @type { string } 4037 * @readonly 4038 * @syscap SystemCapability.Request.FileTransferAgent 4039 * @since 10 4040 */ 4041 /** 4042 * The task details. 4043 * 4044 * @type { string } 4045 * @readonly 4046 * @syscap SystemCapability.Request.FileTransferAgent 4047 * @crossplatform 4048 * @since 11 4049 */ 4050 readonly description: string; 4051 /** 4052 * The task action. 4053 * 4054 * @type { Action } 4055 * @readonly 4056 * @syscap SystemCapability.Request.FileTransferAgent 4057 * @since 10 4058 */ 4059 /** 4060 * The task action. 4061 * 4062 * @type { Action } 4063 * @readonly 4064 * @syscap SystemCapability.Request.FileTransferAgent 4065 * @crossplatform 4066 * @since 11 4067 */ 4068 readonly action: Action; 4069 /** 4070 * Specify task mode. 4071 * The default is frontend and background. 4072 * 4073 * @type { Mode } 4074 * @syscap SystemCapability.Request.FileTransferAgent 4075 * @since 10 4076 */ 4077 /** 4078 * Specify task mode. 4079 * The default is frontend. 4080 * 4081 * @type { Mode } 4082 * @readonly 4083 * @syscap SystemCapability.Request.FileTransferAgent 4084 * @crossplatform 4085 * @since 11 4086 */ 4087 readonly mode: Mode; 4088 /** 4089 * The priority of this task. 4090 * Front-end tasks have higher priority than back-end tasks. 4091 * In tasks of the same mode, the smaller the number, the higher the priority. 4092 * The default is 0. 4093 * 4094 * @type { number } 4095 * @readonly 4096 * @syscap SystemCapability.Request.FileTransferAgent 4097 * @since 11 4098 */ 4099 readonly priority: number; 4100 /** 4101 * The MIME type in the configuration of the task. 4102 * 4103 * @type { string } 4104 * @readonly 4105 * @syscap SystemCapability.Request.FileTransferAgent 4106 * @since 10 4107 */ 4108 /** 4109 * The MIME type in the configuration of the task. 4110 * 4111 * @type { string } 4112 * @readonly 4113 * @syscap SystemCapability.Request.FileTransferAgent 4114 * @crossplatform 4115 * @since 11 4116 */ 4117 readonly mimeType: string; 4118 /** 4119 * An instance of `Progress` for a task. 4120 * 4121 * @type { Progress } 4122 * @readonly 4123 * @syscap SystemCapability.Request.FileTransferAgent 4124 * @since 10 4125 */ 4126 /** 4127 * An instance of `Progress` for a task. 4128 * 4129 * @type { Progress } 4130 * @readonly 4131 * @syscap SystemCapability.Request.FileTransferAgent 4132 * @crossplatform 4133 * @since 11 4134 */ 4135 readonly progress: Progress; 4136 /** 4137 * The progress notification policy of a background task. 4138 * 4139 * @type { boolean } 4140 * @readonly 4141 * @syscap SystemCapability.Request.FileTransferAgent 4142 * @since 10 4143 */ 4144 readonly gauge: boolean; 4145 /** 4146 * The creating date and time of a task in Unix timestamp. 4147 * It is generated by system of current device. 4148 * 4149 * @type { number } 4150 * @readonly 4151 * @syscap SystemCapability.Request.FileTransferAgent 4152 * @since 10 4153 */ 4154 /** 4155 * The creating date and time of a task in Unix timestamp. 4156 * It is generated by system of current device. 4157 * 4158 * @type { number } 4159 * @readonly 4160 * @syscap SystemCapability.Request.FileTransferAgent 4161 * @crossplatform 4162 * @since 11 4163 */ 4164 readonly ctime: number; 4165 /** 4166 * The modified date and time of a task in Unix timestamp. 4167 * It is generated by system of current device. 4168 * 4169 * @type { number } 4170 * @readonly 4171 * @syscap SystemCapability.Request.FileTransferAgent 4172 * @since 10 4173 */ 4174 /** 4175 * The modified date and time of a task in Unix timestamp. 4176 * It is generated by system of current device. 4177 * 4178 * @type { number } 4179 * @readonly 4180 * @syscap SystemCapability.Request.FileTransferAgent 4181 * @crossplatform 4182 * @since 11 4183 */ 4184 readonly mtime: number; 4185 /** 4186 * The retry switch of a task. 4187 * Just for background, frontend always disabled. 4188 * 4189 * @type { boolean } 4190 * @readonly 4191 * @syscap SystemCapability.Request.FileTransferAgent 4192 * @since 10 4193 */ 4194 readonly retry: boolean; 4195 /** 4196 * The tried times of a task. 4197 * 4198 * @type { number } 4199 * @readonly 4200 * @syscap SystemCapability.Request.FileTransferAgent 4201 * @since 10 4202 */ 4203 readonly tries: number; 4204 /** 4205 * The faults case of a task. 4206 * 4207 * @type { Faults } 4208 * @readonly 4209 * @syscap SystemCapability.Request.FileTransferAgent 4210 * @since 10 4211 */ 4212 /** 4213 * The faults case of a task. 4214 * 4215 * @type { Faults } 4216 * @readonly 4217 * @syscap SystemCapability.Request.FileTransferAgent 4218 * @crossplatform 4219 * @since 11 4220 */ 4221 readonly faults: Faults; 4222 /** 4223 * The reason of a waiting/failed/stopped/paused task. 4224 * 4225 * @type { string } 4226 * @readonly 4227 * @syscap SystemCapability.Request.FileTransferAgent 4228 * @since 10 4229 */ 4230 /** 4231 * The reason of a waiting/failed/stopped/paused task. 4232 * 4233 * @type { string } 4234 * @readonly 4235 * @syscap SystemCapability.Request.FileTransferAgent 4236 * @crossplatform 4237 * @since 11 4238 */ 4239 readonly reason: string; 4240 /** 4241 * The extras of a task. 4242 * For background, the last response from server. 4243 * For frontend, nothing now. 4244 * 4245 * @type { ?object } 4246 * @readonly 4247 * @syscap SystemCapability.Request.FileTransferAgent 4248 * @since 10 4249 */ 4250 /** 4251 * The extras of a task. 4252 * For frontend, nothing now. 4253 * 4254 * @type { ?object } 4255 * @readonly 4256 * @syscap SystemCapability.Request.FileTransferAgent 4257 * @crossplatform 4258 * @since 11 4259 */ 4260 readonly extras?: object; 4261 } 4262 4263 /** 4264 * The HTTP response. 4265 * 4266 * @interface HttpResponse 4267 * @syscap SystemCapability.Request.FileTransferAgent 4268 * @atomicservice 4269 * @since 12 4270 */ 4271 interface HttpResponse { 4272 /** 4273 * The version of the HTTP response. 4274 * 4275 * @type { string } 4276 * @readonly 4277 * @syscap SystemCapability.Request.FileTransferAgent 4278 * @atomicservice 4279 * @since 12 4280 */ 4281 readonly version: string, 4282 /** 4283 * The status code of the HTTP response. 4284 * 4285 * @type { number } 4286 * @readonly 4287 * @syscap SystemCapability.Request.FileTransferAgent 4288 * @atomicservice 4289 * @since 12 4290 */ 4291 readonly statusCode: number, 4292 /** 4293 * The reason of the HTTP response. 4294 * 4295 * @type { string } 4296 * @readonly 4297 * @syscap SystemCapability.Request.FileTransferAgent 4298 * @atomicservice 4299 * @since 12 4300 */ 4301 readonly reason: string, 4302 /** 4303 * The headers of the HTTP response. 4304 * 4305 * @type { Map<string, Array<string>> } 4306 * @readonly 4307 * @syscap SystemCapability.Request.FileTransferAgent 4308 * @atomicservice 4309 * @since 12 4310 */ 4311 readonly headers: Map<string, Array<string>>, 4312 } 4313 4314 /** 4315 * The task entry. 4316 * New task' status is "initialized" and enqueue. 4317 * Can `start` a initialized task. 4318 * Can `pause` a waiting/running/retrying background task. 4319 * Can `resume` a paused background task. 4320 * Can `stop` a running/waiting/retrying task and dequeue it. 4321 * 4322 * @typedef Task 4323 * @syscap SystemCapability.Request.FileTransferAgent 4324 * @since 10 4325 */ 4326 /** 4327 * The task entry. 4328 * New task' status is "initialized" and enqueue. 4329 * Can `start` a initialized task. 4330 * Can `pause` a waiting/running/retrying background task. 4331 * Can `resume` a paused background task. 4332 * Can `stop` a running/waiting/retrying task and dequeue it. 4333 * 4334 * @typedef Task 4335 * @syscap SystemCapability.Request.FileTransferAgent 4336 * @crossplatform 4337 * @atomicservice 4338 * @since 11 4339 */ 4340 interface Task { 4341 /** 4342 * The task id, unique on system. 4343 * Generated automatically by system. 4344 * 4345 * @type { string } 4346 * @readonly 4347 * @syscap SystemCapability.Request.FileTransferAgent 4348 * @since 10 4349 */ 4350 /** 4351 * The task id, unique on system. 4352 * Generated automatically by system. 4353 * 4354 * @type { string } 4355 * @readonly 4356 * @syscap SystemCapability.Request.FileTransferAgent 4357 * @crossplatform 4358 * @atomicservice 4359 * @since 11 4360 */ 4361 readonly tid: string; 4362 /** 4363 * The configurations for the task. 4364 * 4365 * @type { Config } 4366 * @syscap SystemCapability.Request.FileTransferAgent 4367 * @since 10 4368 */ 4369 /** 4370 * The configurations for the task. 4371 * 4372 * @type { Config } 4373 * @syscap SystemCapability.Request.FileTransferAgent 4374 * @crossplatform 4375 * @atomicservice 4376 * @since 11 4377 */ 4378 config: Config; 4379 /** 4380 * Enable the specified callback for a frontend task. 4381 * 4382 * @param { 'progress' } event event types. 4383 * @param { function } callback callback function with a `Progress` argument. 4384 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4385 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4386 * @throws { BusinessError } 21900005 - task mode error. 4387 * @syscap SystemCapability.Request.FileTransferAgent 4388 * @since 10 4389 */ 4390 /** 4391 * Enables the specified callback. 4392 * 4393 * @param { 'progress' } event - event types. 4394 * @param { function } callback - callback function with a `Progress` argument. 4395 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4396 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4397 * @syscap SystemCapability.Request.FileTransferAgent 4398 * @crossplatform 4399 * @atomicservice 4400 * @since 11 4401 */ 4402 on(event: 'progress', callback: (progress: Progress) => void): void; 4403 /** 4404 * Disable the specified callback for a frontend task. 4405 * 4406 * @param { 'progress' } event event types. 4407 * @param { function } callback callback function with a `Progress` argument. 4408 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4409 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4410 * @throws { BusinessError } 21900005 - task mode error. 4411 * @syscap SystemCapability.Request.FileTransferAgent 4412 * @since 10 4413 */ 4414 /** 4415 * Disables the specified callback. 4416 * 4417 * @param { 'progress' } event - event types. 4418 * @param { function } callback - callback function with a `Progress` argument. 4419 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4420 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4421 * @syscap SystemCapability.Request.FileTransferAgent 4422 * @crossplatform 4423 * @atomicservice 4424 * @since 11 4425 */ 4426 off(event: 'progress', callback?: (progress: Progress) => void): void; 4427 /** 4428 * Enable the specified callback for a frontend task. 4429 * 4430 * @param { 'completed' } event event types. 4431 * @param { function } callback callback function with a `Progress` argument. 4432 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4433 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4434 * @throws { BusinessError } 21900005 - task mode error. 4435 * @syscap SystemCapability.Request.FileTransferAgent 4436 * @since 10 4437 */ 4438 /** 4439 * Enables the specified callback. 4440 * 4441 * @param { 'completed' } event - event types. 4442 * @param { function } callback - callback function with a `Progress` argument. 4443 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4444 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4445 * @syscap SystemCapability.Request.FileTransferAgent 4446 * @crossplatform 4447 * @atomicservice 4448 * @since 11 4449 */ 4450 on(event: 'completed', callback: (progress: Progress) => void): void; 4451 /** 4452 * Disable the specified callback for a frontend task. 4453 * 4454 * @param { 'completed' } event event types. 4455 * @param { function } callback callback function with a `Progress` argument. 4456 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4457 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4458 * @throws { BusinessError } 21900005 - task mode error. 4459 * @syscap SystemCapability.Request.FileTransferAgent 4460 * @since 10 4461 */ 4462 /** 4463 * Disables the specified callback. 4464 * 4465 * @param { 'completed' } event - event types. 4466 * @param { function } callback - callback function with a `Progress` argument. 4467 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4468 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4469 * @syscap SystemCapability.Request.FileTransferAgent 4470 * @crossplatform 4471 * @atomicservice 4472 * @since 11 4473 */ 4474 off(event: 'completed', callback?: (progress: Progress) => void): void; 4475 /** 4476 * Enable the specified callback for a frontend task. 4477 * 4478 * @param { 'failed' } event event types. 4479 * @param { function } callback callback function with a `Progress` argument. 4480 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4481 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4482 * @throws { BusinessError } 21900005 - task mode error. 4483 * @syscap SystemCapability.Request.FileTransferAgent 4484 * @since 10 4485 */ 4486 /** 4487 * Enables the specified callback. 4488 * 4489 * @param { 'failed' } event - event types. 4490 * @param { function } callback - callback function with a `Progress` argument. 4491 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4492 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4493 * @syscap SystemCapability.Request.FileTransferAgent 4494 * @crossplatform 4495 * @atomicservice 4496 * @since 11 4497 */ 4498 on(event: 'failed', callback: (progress: Progress) => void): void; 4499 /** 4500 * Disable the specified callback for a frontend task. 4501 * 4502 * @param { 'failed' } event event types. 4503 * @param { function } callback callback function with a `Progress` argument. 4504 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4505 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4506 * @throws { BusinessError } 21900005 - task mode error. 4507 * @syscap SystemCapability.Request.FileTransferAgent 4508 * @since 10 4509 */ 4510 /** 4511 * Disables the specified callback. 4512 * 4513 * @param { 'failed' } event - event types. 4514 * @param { function } callback - callback function with a `Progress` argument. 4515 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4516 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4517 * @syscap SystemCapability.Request.FileTransferAgent 4518 * @crossplatform 4519 * @atomicservice 4520 * @since 11 4521 */ 4522 off(event: 'failed', callback?: (progress: Progress) => void): void; 4523 /** 4524 * Enables the specified callback. 4525 * 4526 * @param { 'pause' } event - event types. 4527 * @param { function } callback - callback function with a `Progress` argument. 4528 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4529 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4530 * @syscap SystemCapability.Request.FileTransferAgent 4531 * @since 11 4532 */ 4533 on(event: 'pause', callback: (progress: Progress) => void): void; 4534 /** 4535 * Disables the specified callback. 4536 * 4537 * @param { 'pause' } event - event types. 4538 * @param { function } callback - callback function with a `Progress` argument. 4539 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4540 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4541 * @syscap SystemCapability.Request.FileTransferAgent 4542 * @since 11 4543 */ 4544 off(event: 'pause', callback?: (progress: Progress) => void): void; 4545 /** 4546 * Enables the specified callback. 4547 * 4548 * @param { 'resume' } event - event types. 4549 * @param { function } callback - callback function with a `Progress` argument. 4550 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4551 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4552 * @syscap SystemCapability.Request.FileTransferAgent 4553 * @since 11 4554 */ 4555 on(event: 'resume', callback: (progress: Progress) => void): void; 4556 /** 4557 * Disables the specified callback. 4558 * 4559 * @param { 'resume' } event - event types. 4560 * @param { function } callback - callback function with a `Progress` argument. 4561 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4562 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4563 * @syscap SystemCapability.Request.FileTransferAgent 4564 * @since 11 4565 */ 4566 off(event: 'resume', callback?: (progress: Progress) => void): void; 4567 /** 4568 * Enables the specified callback. 4569 * 4570 * @param { 'remove' } event - event types. 4571 * @param { function } callback - callback function with a `Progress` argument. 4572 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4573 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4574 * @syscap SystemCapability.Request.FileTransferAgent 4575 * @since 11 4576 */ 4577 on(event: 'remove', callback: (progress: Progress) => void): void; 4578 /** 4579 * Disables the specified callback. 4580 * 4581 * @param { 'remove' } event - event types. 4582 * @param { function } callback - callback function with a `Progress` argument. 4583 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4584 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4585 * @syscap SystemCapability.Request.FileTransferAgent 4586 * @since 11 4587 */ 4588 off(event: 'remove', callback?: (progress: Progress) => void): void; 4589 /** 4590 * Enables the response callback. 4591 * 4592 * @param { 'response' } event - event types. 4593 * @param { Callback<HttpResponse> } callback - callback function with an `HttpResponse` argument. 4594 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4595 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4596 * @syscap SystemCapability.Request.FileTransferAgent 4597 * @atomicservice 4598 * @since 12 4599 */ 4600 on(event: 'response', callback: Callback<HttpResponse>): void; 4601 /** 4602 * Disables the response callback. 4603 * 4604 * @param { 'response' } event - event types. 4605 * @param { Callback<HttpResponse> } callback - callback function with an `HttpResponse` argument. 4606 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters. 4607 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4608 * @syscap SystemCapability.Request.FileTransferAgent 4609 * @atomicservice 4610 * @since 12 4611 */ 4612 off(event: 'response', callback?: Callback<HttpResponse>): void; 4613 /** 4614 * Starts the task. 4615 * 4616 * @permission ohos.permission.INTERNET 4617 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4618 * @throws { BusinessError } 201 - Permission denied. 4619 * @throws { BusinessError } 13400003 - task service ability error. 4620 * @throws { BusinessError } 21900007 - task state error. 4621 * @syscap SystemCapability.Request.FileTransferAgent 4622 * @since 10 4623 */ 4624 /** 4625 * Starts the task. 4626 * 4627 * @permission ohos.permission.INTERNET 4628 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4629 * @throws { BusinessError } 201 - Permission denied. 4630 * @throws { BusinessError } 13400003 - task service ability error. 4631 * @throws { BusinessError } 21900007 - task state error. 4632 * @syscap SystemCapability.Request.FileTransferAgent 4633 * @crossplatform 4634 * @atomicservice 4635 * @since 11 4636 */ 4637 /** 4638 * Starts the task. The following tasks can be started: 4639 * 1. Tasks just created. 4640 * 2. Download tasks that are stopped or become FAILED. 4641 * 4642 * @permission ohos.permission.INTERNET 4643 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4644 * @throws { BusinessError } 201 - Permission denied. 4645 * @throws { BusinessError } 13400003 - task service ability error. 4646 * @throws { BusinessError } 21900007 - task state error. 4647 * @syscap SystemCapability.Request.FileTransferAgent 4648 * @crossplatform 4649 * @atomicservice 4650 * @since 12 4651 */ 4652 start(callback: AsyncCallback<void>): void; 4653 /** 4654 * Starts the task. 4655 * 4656 * @permission ohos.permission.INTERNET 4657 * @returns { Promise<void> } the promise returned by the function. 4658 * @throws { BusinessError } 201 - Permission denied. 4659 * @throws { BusinessError } 13400003 - task service ability error. 4660 * @throws { BusinessError } 21900007 - task state error. 4661 * @syscap SystemCapability.Request.FileTransferAgent 4662 * @since 10 4663 */ 4664 /** 4665 * Starts the task. 4666 * 4667 * @permission ohos.permission.INTERNET 4668 * @returns { Promise<void> } the promise returned by the function. 4669 * @throws { BusinessError } 201 - Permission denied. 4670 * @throws { BusinessError } 13400003 - task service ability error. 4671 * @throws { BusinessError } 21900007 - task state error. 4672 * @syscap SystemCapability.Request.FileTransferAgent 4673 * @crossplatform 4674 * @atomicservice 4675 * @since 11 4676 */ 4677 /** 4678 * Starts the task. The following tasks can be started: 4679 * 1. Tasks just created. 4680 * 2. Download tasks that are stopped or become FAILED. 4681 * 4682 * @permission ohos.permission.INTERNET 4683 * @returns { Promise<void> } the promise returned by the function. 4684 * @throws { BusinessError } 201 - Permission denied. 4685 * @throws { BusinessError } 13400003 - task service ability error. 4686 * @throws { BusinessError } 21900007 - task state error. 4687 * @syscap SystemCapability.Request.FileTransferAgent 4688 * @crossplatform 4689 * @atomicservice 4690 * @since 12 4691 */ 4692 start(): Promise<void>; 4693 /** 4694 * Pauses the background task. 4695 * 4696 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4697 * @throws { BusinessError } 13400003 - task service ability error. 4698 * @throws { BusinessError } 21900005 - task mode error. 4699 * @throws { BusinessError } 21900007 - task state error. 4700 * @syscap SystemCapability.Request.FileTransferAgent 4701 * @since 10 4702 */ 4703 /** 4704 * Pauses the task. 4705 * 4706 * @param { AsyncCallback<void> } callback - callback function with a boolean argument indicating the calling result. 4707 * @throws { BusinessError } 13400003 - task service ability error. 4708 * @throws { BusinessError } 21900007 - task state error. 4709 * @syscap SystemCapability.Request.FileTransferAgent 4710 * @since 11 4711 */ 4712 pause(callback: AsyncCallback<void>): void; 4713 /** 4714 * Pauses the background task. 4715 * 4716 * @returns { Promise<void> } the promise returned by the function. 4717 * @throws { BusinessError } 13400003 - task service ability error. 4718 * @throws { BusinessError } 21900005 - task mode error. 4719 * @throws { BusinessError } 21900007 - task state error. 4720 * @syscap SystemCapability.Request.FileTransferAgent 4721 * @since 10 4722 */ 4723 /** 4724 * Pauses the task. 4725 * 4726 * @returns { Promise<void> } the promise returned by the function. 4727 * @throws { BusinessError } 13400003 - task service ability error. 4728 * @throws { BusinessError } 21900007 - task state error. 4729 * @syscap SystemCapability.Request.FileTransferAgent 4730 * @since 11 4731 */ 4732 pause(): Promise<void>; 4733 /** 4734 * Resumes the background task. 4735 * 4736 * @permission ohos.permission.INTERNET 4737 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4738 * @throws { BusinessError } 201 - Permission denied. 4739 * @throws { BusinessError } 13400003 - task service ability error. 4740 * @throws { BusinessError } 21900005 - task mode error. 4741 * @throws { BusinessError } 21900007 - task state error. 4742 * @syscap SystemCapability.Request.FileTransferAgent 4743 * @since 10 4744 */ 4745 /** 4746 * Resumes the task. 4747 * 4748 * @permission ohos.permission.INTERNET 4749 * @param { AsyncCallback<void> } callback - callback function with a boolean argument indicating the calling result. 4750 * @throws { BusinessError } 201 - Permission denied. 4751 * @throws { BusinessError } 13400003 - task service ability error. 4752 * @throws { BusinessError } 21900007 - task state error. 4753 * @syscap SystemCapability.Request.FileTransferAgent 4754 * @since 11 4755 */ 4756 resume(callback: AsyncCallback<void>): void; 4757 /** 4758 * Resumes the background task. 4759 * 4760 * @permission ohos.permission.INTERNET 4761 * @returns { Promise<void> } the promise returned by the function. 4762 * @throws { BusinessError } 201 - Permission denied. 4763 * @throws { BusinessError } 13400003 - task service ability error. 4764 * @throws { BusinessError } 21900005 - task mode error. 4765 * @throws { BusinessError } 21900007 - task state error. 4766 * @syscap SystemCapability.Request.FileTransferAgent 4767 * @since 10 4768 */ 4769 /** 4770 * Resumes the task. 4771 * 4772 * @permission ohos.permission.INTERNET 4773 * @returns { Promise<void> } the promise returned by the function. 4774 * @throws { BusinessError } 201 - Permission denied. 4775 * @throws { BusinessError } 13400003 - task service ability error. 4776 * @throws { BusinessError } 21900007 - task state error. 4777 * @syscap SystemCapability.Request.FileTransferAgent 4778 * @since 11 4779 */ 4780 resume(): Promise<void>; 4781 /** 4782 * Stops the task. 4783 * 4784 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4785 * @throws { BusinessError } 13400003 - task service ability error. 4786 * @throws { BusinessError } 21900007 - task state error. 4787 * @syscap SystemCapability.Request.FileTransferAgent 4788 * @since 10 4789 */ 4790 /** 4791 * Stops the task. 4792 * 4793 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result. 4794 * @throws { BusinessError } 13400003 - task service ability error. 4795 * @throws { BusinessError } 21900007 - task state error. 4796 * @syscap SystemCapability.Request.FileTransferAgent 4797 * @crossplatform 4798 * @atomicservice 4799 * @since 11 4800 */ 4801 stop(callback: AsyncCallback<void>): void; 4802 /** 4803 * Stops the task. 4804 * 4805 * @returns { Promise<void> } the promise returned by the function. 4806 * @throws { BusinessError } 13400003 - task service ability error. 4807 * @throws { BusinessError } 21900007 - task state error. 4808 * @syscap SystemCapability.Request.FileTransferAgent 4809 * @since 10 4810 */ 4811 /** 4812 * Stops the task. 4813 * 4814 * @returns { Promise<void> } the promise returned by the function. 4815 * @throws { BusinessError } 13400003 - task service ability error. 4816 * @throws { BusinessError } 21900007 - task state error. 4817 * @syscap SystemCapability.Request.FileTransferAgent 4818 * @crossplatform 4819 * @atomicservice 4820 * @since 11 4821 */ 4822 stop(): Promise<void>; 4823 } 4824 4825 /** 4826 * Creates a task for upload or download and enqueue it. 4827 * Only foreground application can create the frontend task. 4828 * It can deal only one frontend task at a time. 4829 * A in processing frontend task will be forced to stop when its application had switched to background. 4830 * A new frontend task will interrupt a existed in processing frontend task. 4831 * The background task is highly recommended. 4832 * 4833 * @permission ohos.permission.INTERNET 4834 * @param { BaseContext } context context of the caller. 4835 * @param { Config } config configurations for a task. 4836 * @param { AsyncCallback<Task> } callback indicate the callback function to receive Task. 4837 * @throws { BusinessError } 201 - permission denied. 4838 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4839 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4840 * @throws { BusinessError } 13400001 - file operation error. 4841 * @throws { BusinessError } 13400003 - task service ability error. 4842 * @throws { BusinessError } 21900004 - the application task queue is full. 4843 * @throws { BusinessError } 21900005 - task mode error. 4844 * @syscap SystemCapability.Request.FileTransferAgent 4845 * @since 10 4846 */ 4847 /** 4848 * Creates a task for upload or download and enqueue it. 4849 * When an application enters the background, the frontend tasks associated 4850 * with it will gradually be paused until the application returns to the foreground. 4851 * 4852 * @permission ohos.permission.INTERNET 4853 * @param { BaseContext } context context of the caller. 4854 * @param { Config } config configurations for a task. 4855 * @param { AsyncCallback<Task> } callback indicate the callback function to receive Task. 4856 * @throws { BusinessError } 201 - permission denied. 4857 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4858 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4859 * @throws { BusinessError } 13400001 - file operation error. 4860 * @throws { BusinessError } 13400003 - task service ability error. 4861 * @throws { BusinessError } 21900004 - the application task queue is full. 4862 * @throws { BusinessError } 21900005 - task mode error. 4863 * @syscap SystemCapability.Request.FileTransferAgent 4864 * @crossplatform 4865 * @atomicservice 4866 * @since 11 4867 */ 4868 function create(context: BaseContext, config: Config, callback: AsyncCallback<Task>): void; 4869 4870 /** 4871 * Creates a task for upload or download and enqueue it. 4872 * Only foreground application can create the frontend task. 4873 * It can deal only one frontend task at a time. 4874 * A in processing frontend task will be forced to stop when its application had switched to background. 4875 * A new frontend task will interrupt a existed in processing frontend task. 4876 * The background task is highly recommended. 4877 * 4878 * @permission ohos.permission.INTERNET 4879 * @param { BaseContext } context context of the caller. 4880 * @param { Config } config configurations for a task. 4881 * @returns { Promise<Task> } the promise returned by the function. 4882 * @throws { BusinessError } 201 - permission denied. 4883 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4884 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4885 * @throws { BusinessError } 13400001 - file operation error. 4886 * @throws { BusinessError } 13400003 - task service ability error. 4887 * @throws { BusinessError } 21900004 - the application task queue is full. 4888 * @throws { BusinessError } 21900005 - task mode error. 4889 * @syscap SystemCapability.Request.FileTransferAgent 4890 * @since 10 4891 */ 4892 /** 4893 * Creates a task for upload or download and enqueue it. 4894 * When an application enters the background, the frontend tasks associated. 4895 * with it will gradually be paused until the application returns to the foreground. 4896 * 4897 * @permission ohos.permission.INTERNET 4898 * @param { BaseContext } context context of the caller. 4899 * @param { Config } config configurations for a task. 4900 * @returns { Promise<Task> } the promise returned by the function. 4901 * @throws { BusinessError } 201 - permission denied. 4902 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4903 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4904 * @throws { BusinessError } 13400001 - file operation error. 4905 * @throws { BusinessError } 13400003 - task service ability error. 4906 * @throws { BusinessError } 21900004 - the application task queue is full. 4907 * @throws { BusinessError } 21900005 - task mode error. 4908 * @syscap SystemCapability.Request.FileTransferAgent 4909 * @crossplatform 4910 * @atomicservice 4911 * @since 11 4912 */ 4913 function create(context: BaseContext, config: Config): Promise<Task>; 4914 4915 /** 4916 * Gets the task with the specified id. 4917 * 4918 * @param { BaseContext } context - context of the caller. 4919 * @param { string } id - the id of the task. 4920 * @param { string } token - the token of the task, length between 8 and 2048 bytes. 4921 * @returns { Promise<Task> } the promise returned by the function. 4922 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4923 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 4924 * @throws { BusinessError } 13400003 - task service ability error. 4925 * @throws { BusinessError } 21900006 - task not found. 4926 * @syscap SystemCapability.Request.FileTransferAgent 4927 * @since 11 4928 */ 4929 function getTask(context: BaseContext, id: string, token?: string): Promise<Task>; 4930 4931 /** 4932 * Removes specified task belongs to the caller. 4933 * The task will be forced to stop if in processing. 4934 * 4935 * @param { string } id the task id. 4936 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating success or not. 4937 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4938 * <br>2. Incorrect parameter type. 4939 * @throws { BusinessError } 13400003 - task service ability error. 4940 * @throws { BusinessError } 21900006 - task not found. 4941 * @syscap SystemCapability.Request.FileTransferAgent 4942 * @since 10 4943 */ 4944 /** 4945 * Removes specified task belongs to the caller. 4946 * The task will be forced to stop if in processing. 4947 * 4948 * @param { string } id the task id. 4949 * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating success or not. 4950 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4951 * <br>2. Incorrect parameter type. 4952 * @throws { BusinessError } 13400003 - task service ability error. 4953 * @throws { BusinessError } 21900006 - task not found. 4954 * @syscap SystemCapability.Request.FileTransferAgent 4955 * @crossplatform 4956 * @atomicservice 4957 * @since 11 4958 */ 4959 function remove(id: string, callback: AsyncCallback<void>): void; 4960 4961 /** 4962 * Removes specified task belongs to the caller. 4963 * The task will be forced to stop if in processing. 4964 * 4965 * @param { string } id the task id. 4966 * @returns { Promise<void> } the promise returned by the function. 4967 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4968 * <br>2. Incorrect parameter type. 4969 * @throws { BusinessError } 13400003 - task service ability error. 4970 * @throws { BusinessError } 21900006 - task not found. 4971 * @syscap SystemCapability.Request.FileTransferAgent 4972 * @since 10 4973 */ 4974 /** 4975 * Removes specified task belongs to the caller. 4976 * The task will be forced to stop if in processing. 4977 * 4978 * @param { string } id the task id. 4979 * @returns { Promise<void> } the promise returned by the function. 4980 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4981 * <br>2. Incorrect parameter type. 4982 * @throws { BusinessError } 13400003 - task service ability error. 4983 * @throws { BusinessError } 21900006 - task not found. 4984 * @syscap SystemCapability.Request.FileTransferAgent 4985 * @crossplatform 4986 * @atomicservice 4987 * @since 11 4988 */ 4989 function remove(id: string): Promise<void>; 4990 4991 /** 4992 * Shows specified task details belongs to the caller. 4993 * 4994 * @param { string } id the task id. 4995 * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task. 4996 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 4997 * <br>2. Incorrect parameter type. 4998 * @throws { BusinessError } 13400003 - task service ability error. 4999 * @throws { BusinessError } 21900006 - task not found. 5000 * @syscap SystemCapability.Request.FileTransferAgent 5001 * @since 10 5002 */ 5003 /** 5004 * Shows specified task details belongs to the caller. 5005 * 5006 * @param { string } id the task id. 5007 * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task. 5008 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5009 * <br>2. Incorrect parameter type. 5010 * @throws { BusinessError } 13400003 - task service ability error. 5011 * @throws { BusinessError } 21900006 - task not found. 5012 * @syscap SystemCapability.Request.FileTransferAgent 5013 * @crossplatform 5014 * @since 11 5015 */ 5016 function show(id: string, callback: AsyncCallback<TaskInfo>): void; 5017 5018 /** 5019 * Shows specified task details belongs to the caller. 5020 * 5021 * @param { string } id the task id. 5022 * @returns { Promise<TaskInfo> } the promise returned by the function. 5023 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5024 * <br>2. Incorrect parameter type. 5025 * @throws { BusinessError } 13400003 - task service ability error. 5026 * @throws { BusinessError } 21900006 - task not found. 5027 * @syscap SystemCapability.Request.FileTransferAgent 5028 * @since 10 5029 */ 5030 /** 5031 * Shows specified task details belongs to the caller. 5032 * 5033 * @param { string } id the task id. 5034 * @returns { Promise<TaskInfo> } the promise returned by the function. 5035 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5036 * <br>2. Incorrect parameter type. 5037 * @throws { BusinessError } 13400003 - task service ability error. 5038 * @throws { BusinessError } 21900006 - task not found. 5039 * @syscap SystemCapability.Request.FileTransferAgent 5040 * @crossplatform 5041 * @since 11 5042 */ 5043 function show(id: string): Promise<TaskInfo>; 5044 5045 /** 5046 * Touches specified task with token. 5047 * 5048 * @param { string } id the task id. 5049 * @param { string } token the in-application isolation key. 5050 * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task. 5051 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5052 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 5053 * @throws { BusinessError } 13400003 - task service ability error. 5054 * @throws { BusinessError } 21900006 - task not found. 5055 * @syscap SystemCapability.Request.FileTransferAgent 5056 * @since 10 5057 */ 5058 /** 5059 * Touches specified task with token. 5060 * 5061 * @param { string } id the task id. 5062 * @param { string } token the in-application isolation key, length between 8 and 2048 bytes. 5063 * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task. 5064 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5065 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 5066 * @throws { BusinessError } 13400003 - task service ability error. 5067 * @throws { BusinessError } 21900006 - task not found. 5068 * @syscap SystemCapability.Request.FileTransferAgent 5069 * @crossplatform 5070 * @since 11 5071 */ 5072 function touch(id: string, token: string, callback: AsyncCallback<TaskInfo>): void; 5073 5074 /** 5075 * Touches specified task with token. 5076 * 5077 * @param { string } id the task id. 5078 * @param { string } token the in-application isolation key, length between 8 and 2048 bytes. 5079 * @returns { Promise<TaskInfo> } the promise returned by the function. 5080 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5081 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 5082 * @throws { BusinessError } 13400003 - task service ability error. 5083 * @throws { BusinessError } 21900006 - task not found. 5084 * @syscap SystemCapability.Request.FileTransferAgent 5085 * @since 10 5086 */ 5087 /** 5088 * Touches specified task with token. 5089 * 5090 * @param { string } id the task id. 5091 * @param { string } token the in-application isolation key, length between 8 and 2048 bytes. 5092 * @returns { Promise<TaskInfo> } the promise returned by the function. 5093 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5094 * <br>2. Incorrect parameter type. 3. Parameter verification failed. 5095 * @throws { BusinessError } 13400003 - task service ability error. 5096 * @throws { BusinessError } 21900006 - task not found. 5097 * @syscap SystemCapability.Request.FileTransferAgent 5098 * @crossplatform 5099 * @since 11 5100 */ 5101 function touch(id: string, token: string): Promise<TaskInfo>; 5102 5103 /** 5104 * Searches tasks, for system. 5105 * 5106 * @param { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter. 5107 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type. 5108 * <br>2. Parameter verification failed. 5109 * @throws { BusinessError } 13400003 - task service ability error. 5110 * @syscap SystemCapability.Request.FileTransferAgent 5111 * @since 10 5112 */ 5113 /** 5114 * Searches tasks, for system. 5115 * 5116 * @param { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter. 5117 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type. 5118 * <br>2. Parameter verification failed. 5119 * @throws { BusinessError } 13400003 - task service ability error. 5120 * @syscap SystemCapability.Request.FileTransferAgent 5121 * @crossplatform 5122 * @since 11 5123 */ 5124 function search(callback: AsyncCallback<Array<string>>): void; 5125 5126 /** 5127 * Searches tasks, for system. 5128 * 5129 * @param { Filter } filter an instance of `Filter`. 5130 * @param { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter. 5131 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type. 5132 * <br>2. Parameter verification failed. 5133 * @throws { BusinessError } 13400003 - task service ability error. 5134 * @syscap SystemCapability.Request.FileTransferAgent 5135 * @since 10 5136 */ 5137 /** 5138 * Searches tasks, for system. 5139 * 5140 * @param { Filter } filter an instance of `Filter`. 5141 * @param { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter. 5142 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type. 5143 * <br>2. Parameter verification failed. 5144 * @throws { BusinessError } 13400003 - task service ability error. 5145 * @syscap SystemCapability.Request.FileTransferAgent 5146 * @crossplatform 5147 * @since 11 5148 */ 5149 function search(filter: Filter, callback: AsyncCallback<Array<string>>): void; 5150 5151 /** 5152 * Searches tasks, for system. 5153 * 5154 * @param { Filter } filter an instance of `Filter`. 5155 * @returns { Promise<Array<string>> } the promise returned by the function. 5156 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type. 5157 * <br>2. Parameter verification failed. 5158 * @throws { BusinessError } 13400003 - task service ability error. 5159 * @syscap SystemCapability.Request.FileTransferAgent 5160 * @since 10 5161 */ 5162 /** 5163 * Searches tasks, for system. 5164 * 5165 * @param { Filter } filter an instance of `Filter`. 5166 * @returns { Promise<Array<string>> } the promise returned by the function. 5167 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type. 5168 * <br>2. Parameter verification failed. 5169 * @throws { BusinessError } 13400003 - task service ability error. 5170 * @syscap SystemCapability.Request.FileTransferAgent 5171 * @crossplatform 5172 * @since 11 5173 */ 5174 function search(filter?: Filter): Promise<Array<string>>; 5175 5176 /** 5177 * Queries specified task details. 5178 * 5179 * @permission ohos.permission.DOWNLOAD_SESSION_MANAGER or ohos.permission.UPLOAD_SESSION_MANAGER 5180 * @param { string } id the task id. 5181 * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task. 5182 * @throws { BusinessError } 201 - permission denied. 5183 * @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API. 5184 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5185 * <br>2. Incorrect parameter type. 5186 * @throws { BusinessError } 13400003 - task service ability error. 5187 * @throws { BusinessError } 21900006 - task not found. 5188 * @syscap SystemCapability.Request.FileTransferAgent 5189 * @systemapi Hide this for inner system use. 5190 * @since 10 5191 */ 5192 function query(id: string, callback: AsyncCallback<TaskInfo>): void; 5193 5194 /** 5195 * Queries specified task details. 5196 * 5197 * @permission ohos.permission.DOWNLOAD_SESSION_MANAGER or ohos.permission.UPLOAD_SESSION_MANAGER 5198 * @param { string } id the task id. 5199 * @returns { Promise<TaskInfo> } the promise returned by the function. 5200 * @throws { BusinessError } 201 - permission denied. 5201 * @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API. 5202 * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters. 5203 * <br>2. Incorrect parameter type. 5204 * @throws { BusinessError } 13400003 - task service ability error. 5205 * @throws { BusinessError } 21900006 - task not found. 5206 * @syscap SystemCapability.Request.FileTransferAgent 5207 * @systemapi Hide this for inner system use. 5208 * @since 10 5209 */ 5210 function query(id: string): Promise<TaskInfo>; 5211 } 5212} 5213 5214export default request; 5215