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