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