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