• 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       * @deprecated since 18
2679       * @useinstead ohos.request.agent.FileSpec.contentType
2680       */
2681      mimeType?: string;
2682      /**
2683       * Sets the content-type field of the part.
2684       * The default is obtained by the suffix of the filename.
2685       *
2686       * @type { ?string }
2687       * @syscap SystemCapability.Request.FileTransferAgent
2688       * @since 18
2689       */
2690      contentType?: string;
2691      /**
2692       * The filename, the default is obtained by path.
2693       *
2694       * @type { ?string }
2695       * @syscap SystemCapability.Request.FileTransferAgent
2696       * @since 10
2697       */
2698      /**
2699       * The filename, the default is obtained by path.
2700       *
2701       * @type { ?string }
2702       * @syscap SystemCapability.Request.FileTransferAgent
2703       * @crossplatform
2704       * @atomicservice
2705       * @since 11
2706       */
2707      filename?: string;
2708      /**
2709       * The extras for the file information.
2710       *
2711       * @type { ?object }
2712       * @syscap SystemCapability.Request.FileTransferAgent
2713       * @since 10
2714       */
2715      /**
2716       * The extras for the file information.
2717       *
2718       * @type { ?object }
2719       * @syscap SystemCapability.Request.FileTransferAgent
2720       * @crossplatform
2721       * @atomicservice
2722       * @since 11
2723       */
2724      extras?: object;
2725    }
2726
2727    /**
2728     * The form item information for a task.
2729     *
2730     * @typedef FormItem
2731     * @syscap SystemCapability.Request.FileTransferAgent
2732     * @since 10
2733     */
2734    /**
2735     * The form item information for a task.
2736     *
2737     * @typedef FormItem
2738     * @syscap SystemCapability.Request.FileTransferAgent
2739     * @crossplatform
2740     * @atomicservice
2741     * @since 11
2742     */
2743    interface FormItem {
2744      /**
2745       * The item's name.
2746       *
2747       * @type { string }
2748       * @syscap SystemCapability.Request.FileTransferAgent
2749       * @since 10
2750       */
2751      /**
2752       * The item's name.
2753       *
2754       * @type { string }
2755       * @syscap SystemCapability.Request.FileTransferAgent
2756       * @crossplatform
2757       * @atomicservice
2758       * @since 11
2759       */
2760      name: string;
2761      /**
2762       * The item's value.
2763       *
2764       * @type { string | FileSpec | Array<FileSpec> }
2765       * @syscap SystemCapability.Request.FileTransferAgent
2766       * @since 10
2767       */
2768      /**
2769       * The item's value.
2770       *
2771       * @type { string | FileSpec | Array<FileSpec> }
2772       * @syscap SystemCapability.Request.FileTransferAgent
2773       * @crossplatform
2774       * @atomicservice
2775       * @since 11
2776       */
2777      value: string | FileSpec | Array<FileSpec>;
2778    }
2779
2780    /**
2781     * Options of the custom notification of backend tasks.
2782     *
2783     * @typedef Notification
2784     * @syscap SystemCapability.Request.FileTransferAgent
2785     * @since 15
2786     */
2787    interface Notification {
2788      /**
2789       * The title of the notification.
2790       * If not specified, use default style instead.
2791       * The maximum size of title is 1024 bytes.
2792       *
2793       * @type { ?string }
2794       * @syscap SystemCapability.Request.FileTransferAgent
2795       * @since 15
2796       */
2797      title?: string;
2798      /**
2799       * The text of the notification.
2800       * If not specified, use the file name of the task instead.
2801       * The maximum size of text is 3072 bytes.
2802       *
2803       * @type { ?string }
2804       * @syscap SystemCapability.Request.FileTransferAgent
2805       * @since 15
2806       */
2807      text?: string;
2808    }
2809
2810    /**
2811     * The configurations for a task.
2812     * Using a flexible configuration for clear upload and download functions.
2813     * If without emphasis, an option is for any task.
2814     *
2815     * @typedef Config
2816     * @syscap SystemCapability.Request.FileTransferAgent
2817     * @since 10
2818     */
2819    /**
2820     * The configurations for a task.
2821     * Using a flexible configuration for clear upload and download functions.
2822     * If without emphasis, an option is for any task.
2823     *
2824     * @typedef Config
2825     * @syscap SystemCapability.Request.FileTransferAgent
2826     * @crossplatform
2827     * @atomicservice
2828     * @since 11
2829     */
2830    interface Config {
2831      /**
2832       * The task action, upload or download.
2833       *
2834       * @type { Action }
2835       * @syscap SystemCapability.Request.FileTransferAgent
2836       * @since 10
2837       */
2838      /**
2839       * The task action, upload or download.
2840       *
2841       * @type { Action }
2842       * @syscap SystemCapability.Request.FileTransferAgent
2843       * @crossplatform
2844       * @atomicservice
2845       * @since 11
2846       */
2847      action: Action;
2848      /**
2849       * The Universal Resource Locator for a task.
2850       * Starting with http(s)://
2851       * The maximum length is 2048 characters.
2852       * Using raw `url` option, even url parameters in it.
2853       *
2854       * @type { string }
2855       * @syscap SystemCapability.Request.FileTransferAgent
2856       * @since 10
2857       */
2858      /**
2859       * The Universal Resource Locator for a task.
2860       * The maximum length is 2048 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 11
2868       */
2869      /**
2870       * The Universal Resource Locator for a task.
2871       * The maximum length is 8192 characters.
2872       * Using raw `url` option, even url parameters in it.
2873       *
2874       * @type { string }
2875       * @syscap SystemCapability.Request.FileTransferAgent
2876       * @crossplatform
2877       * @atomicservice
2878       * @since 15
2879       */
2880      url: string;
2881      /**
2882       * The title for a task, give a meaningful title please.
2883       * The maximum length is 256 characters.
2884       * The default is the same with its action.
2885       *
2886       * @type { ?string }
2887       * @syscap SystemCapability.Request.FileTransferAgent
2888       * @since 10
2889       */
2890      /**
2891       * The title for a task, give a meaningful title please.
2892       * The maximum length is 256 characters.
2893       * The default is upload or download, consistent with its action.
2894       *
2895       * @type { ?string }
2896       * @syscap SystemCapability.Request.FileTransferAgent
2897       * @crossplatform
2898       * @atomicservice
2899       * @since 11
2900       */
2901      title?: string;
2902      /**
2903       * The details for a task.
2904       * The maximum length is 1024 characters.
2905       * The default is empty string.
2906       *
2907       * @type { ?string }
2908       * @syscap SystemCapability.Request.FileTransferAgent
2909       * @since 10
2910       */
2911      /**
2912       * The details for a task.
2913       * The maximum length is 1024 characters.
2914       * The default is empty string.
2915       *
2916       * @type { ?string }
2917       * @syscap SystemCapability.Request.FileTransferAgent
2918       * @crossplatform
2919       * @atomicservice
2920       * @since 11
2921       */
2922      description?: string;
2923      /**
2924       * Indicates task's mode.
2925       * The default is background.
2926       * For frontend task, it has callbacks.
2927       * For background task, it has notifications and fallback.
2928       *
2929       * @type { ?Mode }
2930       * @syscap SystemCapability.Request.FileTransferAgent
2931       * @since 10
2932       */
2933      /**
2934       * Indicates task's mode.
2935       * The default is BACKGROUND.
2936       * For frontend task, it has callbacks.
2937       * For background task, it has notifications and fallback.
2938       * The cross-platform default is FOREGROUND.
2939       *
2940       * @type { ?Mode }
2941       * @syscap SystemCapability.Request.FileTransferAgent
2942       * @crossplatform
2943       * @atomicservice
2944       * @since 11
2945       */
2946
2947      mode?: Mode;
2948      /**
2949       * The solution choice when path already exists during download.
2950       * Currently support:
2951       * true, rewrite the existed file.
2952       * false, go to fail.
2953       *
2954       * @type { ?boolean }
2955       * @syscap SystemCapability.Request.FileTransferAgent
2956       * @since 10
2957       */
2958      /**
2959       * The solution choice when path already exists during download.
2960       * The default is false.
2961       * Currently support:
2962       * true, rewrite the existed file.
2963       * false, go to fail.
2964       *
2965       * @type { ?boolean }
2966       * @syscap SystemCapability.Request.FileTransferAgent
2967       * @crossplatform
2968       * @atomicservice
2969       * @since 11
2970       */
2971      overwrite?: boolean;
2972      /**
2973       * The HTTP standard method for upload or download: GET/POST/PUT.
2974       * Case insensitive.
2975       * For upload, use PUT/POST, the default is PUT.
2976       * For download, use GET/POST, the default is GET.
2977       *
2978       * @type { ?string }
2979       * @syscap SystemCapability.Request.FileTransferAgent
2980       * @since 10
2981       */
2982      /**
2983       * The HTTP standard method for upload or download: GET/POST/PUT.
2984       * Case insensitive.
2985       * For upload, use PUT/POST, the default is PUT.
2986       * For download, use GET/POST, the default is GET.
2987       *
2988       * @type { ?string }
2989       * @syscap SystemCapability.Request.FileTransferAgent
2990       * @crossplatform
2991       * @atomicservice
2992       * @since 11
2993       */
2994      method?: string;
2995      /**
2996       * The HTTP headers.
2997       * For upload request, the `Content-Type` is forced to `multipart/form-data`.
2998       * For download request, the default `Content-Type` is `application/json`.
2999       *
3000       * @type { ?object }
3001       * @syscap SystemCapability.Request.FileTransferAgent
3002       * @since 10
3003       */
3004      /**
3005       * The HTTP headers.
3006       * For upload request, the `Content-Type` is forced to `multipart/form-data`.
3007       * For download request, the default `Content-Type` is `application/json`.
3008       *
3009       * @type { ?object }
3010       * @syscap SystemCapability.Request.FileTransferAgent
3011       * @crossplatform
3012       * @atomicservice
3013       * @since 11
3014       */
3015      headers?: object;
3016      /**
3017       * The arguments, it can be any text, uses json usually.
3018       * For download, it can be raw string, the default is empty string.
3019       * For upload, it can be form items, the default is a empty form.
3020       * there must be one `FileSpec` item at least or will be a parameter error.
3021       *
3022       * @type { ?(string | Array<FormItem>) }
3023       * @syscap SystemCapability.Request.FileTransferAgent
3024       * @since 10
3025       */
3026      /**
3027       * The arguments, it can be any text, uses json usually.
3028       * For download, it can be raw string, the default is empty string.
3029       * For upload, it can be form items, the default is a empty form.
3030       * there must be one `FileSpec` item at least or will be a parameter error.
3031       *
3032       * @type { ?(string | Array<FormItem>) }
3033       * @syscap SystemCapability.Request.FileTransferAgent
3034       * @crossplatform
3035       * @atomicservice
3036       * @since 11
3037       */
3038      data?: string | Array<FormItem>;
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       * @since 10
3049       */
3050      /**
3051       * The path to save the downloaded file, the default is "./".
3052       * Currently support:
3053       * 1: relative path, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", under caller's cache folder.
3054       * 2: uri path, like "datashare://bundle/xxx/yyy/zzz.html", the data provider must allow the caller's access.
3055       *
3056       * @type { ?string }
3057       * @default ./
3058       * @syscap SystemCapability.Request.FileTransferAgent
3059       * @crossplatform
3060       * @atomicservice
3061       * @since 11
3062       */
3063      /**
3064       * The path to save the downloaded file, the default is "./".
3065       * Currently support:
3066       * 1: relative path, like "./xxx/yyy/zzz.html", "xxx/yyy/zzz.html", under caller's cache folder.
3067       * 2: internal protocol path, starting with "internal://", like "internal://cache/path/to/file.txt".
3068       * 3: application storage path, only the base directory and its subdirectories are supported, like "/data/storage/el1/base/path/to/file.txt".
3069       * 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".
3070       *
3071       * @type { ?string }
3072       * @default ./
3073       * @syscap SystemCapability.Request.FileTransferAgent
3074       * @crossplatform
3075       * @atomicservice
3076       * @since 12
3077       */
3078      saveas?: string;
3079      /**
3080       * The network.
3081       *
3082       * @type { ?Network }
3083       * @default Network.ANY
3084       * @syscap SystemCapability.Request.FileTransferAgent
3085       * @since 10
3086       */
3087      /**
3088       * The network.
3089       *
3090       * @type { ?Network }
3091       * @default Network.ANY
3092       * @syscap SystemCapability.Request.FileTransferAgent
3093       * @crossplatform
3094       * @atomicservice
3095       * @since 11
3096       */
3097      network?: Network;
3098      /**
3099       * Allows work in metered network or not.
3100       * The default is false.
3101       *
3102       * @type { ?boolean }
3103       * @default false
3104       * @syscap SystemCapability.Request.FileTransferAgent
3105       * @since 10
3106       */
3107      /**
3108       * Allows work in metered network or not.
3109       * The default is false.
3110       *
3111       * @type { ?boolean }
3112       * @default false
3113       * @syscap SystemCapability.Request.FileTransferAgent
3114       * @crossplatform
3115       * @atomicservice
3116       * @since 11
3117       */
3118      metered?: boolean;
3119      /**
3120       * Allows work in roaming network or not.
3121       * The default is true.
3122       *
3123       * @type { ?boolean }
3124       * @syscap SystemCapability.Request.FileTransferAgent
3125       * @since 10
3126       */
3127      /**
3128       * Allows work in roaming network or not.
3129       * The default is true.
3130       *
3131       * @type { ?boolean }
3132       * @syscap SystemCapability.Request.FileTransferAgent
3133       * @crossplatform
3134       * @atomicservice
3135       * @since 11
3136       */
3137      roaming?: boolean;
3138      /**
3139       * Enable automatic retry or not for the background task.
3140       * The frontend task is always fast-fail.
3141       *
3142       * @type { ?boolean }
3143       * @syscap SystemCapability.Request.FileTransferAgent
3144       * @since 10
3145       */
3146      /**
3147       * Enable automatic retry or not for the background task.
3148       * The frontend task is always fast-fail.
3149       *
3150       * @type { ?boolean }
3151       * @syscap SystemCapability.Request.FileTransferAgent
3152       * @atomicservice
3153       * @since 11
3154       */
3155      retry?: boolean;
3156      /**
3157       * Allows redirect or not.
3158       * The default is yes.
3159       *
3160       * @type { ?boolean }
3161       * @syscap SystemCapability.Request.FileTransferAgent
3162       * @since 10
3163       */
3164      /**
3165       * Allows redirect or not.
3166       * The default is true.
3167       *
3168       * @type { ?boolean }
3169       * @syscap SystemCapability.Request.FileTransferAgent
3170       * @crossplatform
3171       * @atomicservice
3172       * @since 11
3173       */
3174      redirect?: boolean;
3175      /**
3176       * The proxy url for the task.
3177       * Only this format is supported: http://<domain or IP-address>:<port>
3178       * Username and password are not supported.
3179       *
3180       * @type { ?string }
3181       * @syscap SystemCapability.Request.FileTransferAgent
3182       * @since 12
3183       */
3184      proxy?: string;
3185      /**
3186       * The index of paths for a task.
3187       * Usually used for a continuous job.
3188       * The default is 0.
3189       *
3190       * @type { ?number }
3191       * @syscap SystemCapability.Request.FileTransferAgent
3192       * @since 10
3193       */
3194      /**
3195       * The index of paths for a task.
3196       * Usually used for a continuous job.
3197       * The default is 0.
3198       *
3199       * @type { ?number }
3200       * @syscap SystemCapability.Request.FileTransferAgent
3201       * @crossplatform
3202       * @atomicservice
3203       * @since 11
3204       */
3205      index?: number;
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       * @since 10
3216       */
3217      /**
3218       * The start point of a file.
3219       * Usually used for a continuous job.
3220       * It will set the "Range" header in download.
3221       * It will start read at the point in upload.
3222       * The default is 0.
3223       *
3224       * @type { ?number }
3225       * @syscap SystemCapability.Request.FileTransferAgent
3226       * @crossplatform
3227       * @atomicservice
3228       * @since 11
3229       */
3230      begins?: number;
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       * @since 10
3241       */
3242      /**
3243       * The end point of a file.
3244       * Usually used for a continuous job.
3245       * It will set The "Range" header in download.
3246       * It will end read at the point in upload.
3247       * The default is -1 indicating the end of the data for upload or download.
3248       *
3249       * @type { ?number }
3250       * @syscap SystemCapability.Request.FileTransferAgent
3251       * @crossplatform
3252       * @atomicservice
3253       * @since 11
3254       */
3255      ends?: number;
3256      /**
3257       * The policy of the progress notification for background task.
3258       * If false: only completed or failed notification, the default.
3259       * If true, emits every progress, completed or failed notifications.
3260       *
3261       * @type { ?boolean }
3262       * @syscap SystemCapability.Request.FileTransferAgent
3263       * @since 10
3264       */
3265      /**
3266       * The policy of the progress notification for background task.
3267       * If false: only completed or failed notification, the default.
3268       * If true, emits every progress, completed or failed notifications.
3269       *
3270       * @type { ?boolean }
3271       * @syscap SystemCapability.Request.FileTransferAgent
3272       * @atomicservice
3273       * @since 11
3274       */
3275      gauge?: boolean;
3276      /**
3277       * Breaks when fail to fetch filesize before upload/download or not.
3278       * Uses filesize for a precise gauge.
3279       * The default is not, set size as -1 indicating the case.
3280       *
3281       * @type { ?boolean }
3282       * @syscap SystemCapability.Request.FileTransferAgent
3283       * @since 10
3284       */
3285      /**
3286       * Breaks when fail to fetch filesize before upload/download or not.
3287       * Uses filesize for a precise gauge.
3288       * The default is false, set size as -1 indicating the case.
3289       *
3290       * @type { ?boolean }
3291       * @syscap SystemCapability.Request.FileTransferAgent
3292       * @crossplatform
3293       * @atomicservice
3294       * @since 11
3295       */
3296      precise?: boolean;
3297      /**
3298       * For in-application layer isolation.
3299       * If given:
3300       *   the minimum is 8 bytes.
3301       *   the maximum is 2048 bytes.
3302       * Creates a task with token, then must provide it during normal query.
3303       * So saves the token carefully, it can not be retrieved by query.
3304       * Or leave it empty.
3305       *
3306       * @type { ?string }
3307       * @syscap SystemCapability.Request.FileTransferAgent
3308       * @since 10
3309       */
3310      /**
3311       * For in-application layer isolation.
3312       * If given:
3313       *   the minimum is 8 bytes.
3314       *   the maximum is 2048 bytes.
3315       * Creates a task with token, then must provide it during normal query.
3316       * So saves the token carefully, it can not be retrieved by query.
3317       * Or leave it empty.
3318       *
3319       * @type { ?string }
3320       * @syscap SystemCapability.Request.FileTransferAgent
3321       * @crossplatform
3322       * @atomicservice
3323       * @since 11
3324       */
3325      token?: string;
3326      /**
3327       * The priority of this task.
3328       * Front-end tasks have higher priority than back-end tasks.
3329       * In tasks of the same mode, the smaller the number, the higher the priority.
3330       * The default is 0.
3331       *
3332       * @type { ?number }
3333       * @syscap SystemCapability.Request.FileTransferAgent
3334       * @since 11
3335       */
3336      priority?: number;
3337      /**
3338       * The extras for the configuration.
3339       *
3340       * @type { ?object }
3341       * @syscap SystemCapability.Request.FileTransferAgent
3342       * @since 10
3343       */
3344      /**
3345       * The extras for the configuration.
3346       *
3347       * @type { ?object }
3348       * @syscap SystemCapability.Request.FileTransferAgent
3349       * @crossplatform
3350       * @atomicservice
3351       * @since 11
3352       */
3353      extras?: object;
3354      /**
3355       * Use a single request to upload multiple files.
3356       * If true, use the form format to merge multiple files into one request.
3357       * If false, use independent requests to send each file.
3358       * The default is false.
3359       *
3360       * @type { ?boolean }
3361       * @syscap SystemCapability.Request.FileTransferAgent
3362       * @since 15
3363       */
3364      multipart?: boolean;
3365      /**
3366       * Customizes the notification of the backend task.
3367       *
3368       * @type { ?Notification }
3369       * @syscap SystemCapability.Request.FileTransferAgent
3370       * @since 15
3371       */
3372      notification?: Notification;
3373    }
3374
3375    /**
3376     * Indicate the current state of the task.
3377     *
3378     * @enum { number } State
3379     * @syscap SystemCapability.Request.FileTransferAgent
3380     * @since 10
3381     */
3382    /**
3383     * Indicate the current state of the task.
3384     *
3385     * @enum { number } State
3386     * @syscap SystemCapability.Request.FileTransferAgent
3387     * @crossplatform
3388     * @atomicservice
3389     * @since 11
3390     */
3391    enum State {
3392      /**
3393       * Indicates a task created by `new Task(Config)`.
3394       *
3395       * @syscap SystemCapability.Request.FileTransferAgent
3396       * @since 10
3397       */
3398      /**
3399       * Indicates a task created by `new Task(Config)`.
3400       *
3401       * @syscap SystemCapability.Request.FileTransferAgent
3402       * @crossplatform
3403       * @atomicservice
3404       * @since 11
3405       */
3406      INITIALIZED = 0x00,
3407      /**
3408       * Indicates a task lack of resources or conditions to run or retry.
3409       *
3410       * @syscap SystemCapability.Request.FileTransferAgent
3411       * @since 10
3412       */
3413      /**
3414       * Indicates a task lack of resources or conditions to run or retry.
3415       *
3416       * @syscap SystemCapability.Request.FileTransferAgent
3417       * @crossplatform
3418       * @atomicservice
3419       * @since 11
3420       */
3421      WAITING = 0x10,
3422      /**
3423       * Indicates a task in processing now.
3424       *
3425       * @syscap SystemCapability.Request.FileTransferAgent
3426       * @since 10
3427       */
3428      /**
3429       * Indicates a task in processing now.
3430       *
3431       * @syscap SystemCapability.Request.FileTransferAgent
3432       * @crossplatform
3433       * @atomicservice
3434       * @since 11
3435       */
3436      RUNNING = 0x20,
3437      /**
3438       * Indicates a task failed once at least and in processing again now.
3439       *
3440       * @syscap SystemCapability.Request.FileTransferAgent
3441       * @since 10
3442       */
3443      /**
3444       * Indicates a task failed once at least and in processing again now.
3445       *
3446       * @syscap SystemCapability.Request.FileTransferAgent
3447       * @crossplatform
3448       * @atomicservice
3449       * @since 11
3450       */
3451      RETRYING = 0x21,
3452      /**
3453       * Indicates a paused task which tends to be resumed for continuous work.
3454       *
3455       * @syscap SystemCapability.Request.FileTransferAgent
3456       * @since 10
3457       */
3458      /**
3459       * Indicates a paused task which tends to be resumed for continuous work.
3460       *
3461       * @syscap SystemCapability.Request.FileTransferAgent
3462       * @crossplatform
3463       * @atomicservice
3464       * @since 11
3465       */
3466      PAUSED = 0x30,
3467      /**
3468       * Indicates a stopped task which must be started again.
3469       *
3470       * @syscap SystemCapability.Request.FileTransferAgent
3471       * @since 10
3472       */
3473      /**
3474       * Indicates a stopped task which must be started again.
3475       *
3476       * @syscap SystemCapability.Request.FileTransferAgent
3477       * @crossplatform
3478       * @atomicservice
3479       * @since 11
3480       */
3481      STOPPED = 0x31,
3482      /**
3483       * Indicates a completed task which finish its data transfer.
3484       *
3485       * @syscap SystemCapability.Request.FileTransferAgent
3486       * @since 10
3487       */
3488      /**
3489       * Indicates a completed task which finish its data transfer.
3490       *
3491       * @syscap SystemCapability.Request.FileTransferAgent
3492       * @crossplatform
3493       * @atomicservice
3494       * @since 11
3495       */
3496      COMPLETED = 0x40,
3497      /**
3498       * Indicates a failed task which interrupted by some error.
3499       *
3500       * @syscap SystemCapability.Request.FileTransferAgent
3501       * @since 10
3502       */
3503      /**
3504       * Indicates a failed task which interrupted by some error.
3505       *
3506       * @syscap SystemCapability.Request.FileTransferAgent
3507       * @crossplatform
3508       * @atomicservice
3509       * @since 11
3510       */
3511      FAILED = 0x41,
3512      /**
3513       * Indicates a removed task which can not be processed again.
3514       *
3515       * @syscap SystemCapability.Request.FileTransferAgent
3516       * @since 10
3517       */
3518      /**
3519       * Indicates a removed task which can not be processed again.
3520       *
3521       * @syscap SystemCapability.Request.FileTransferAgent
3522       * @crossplatform
3523       * @atomicservice
3524       * @since 11
3525       */
3526      REMOVED = 0x50
3527    }
3528
3529    /**
3530     * The progress data structure.
3531     * Upload allows multiple files per upload task.
3532     * Only one file in a download task.
3533     * So using a unified data structure for progress.
3534     * Generally:
3535     * 1: sum(sizes) is total files size of the task.
3536     * 2: float(processed)/sizes[counter] is the progress for the current processing file.
3537     * 3: float(sum(sizes[:index])+processed)/sum(sizes) is the summary progress for a task.
3538     * If fetch file size in failure, the size of the file in sizes will be set as -1.
3539     *
3540     * @typedef Progress
3541     * @syscap SystemCapability.Request.FileTransferAgent
3542     * @since 10
3543     */
3544    /**
3545     * The progress data structure.
3546     * Upload allows multiple files per upload task.
3547     * Only one file in a download task.
3548     * So using a unified data structure for progress.
3549     * Generally:
3550     * 1: sum(sizes) is total files size of the task.
3551     * 2: float(processed)/sizes[counter] is the progress for the current processing file.
3552     * 3: float(sum(sizes[:index])+processed)/sum(sizes) is the summary progress for a task.
3553     * If fetch file size in failure, the size of the file in sizes will be set as -1.
3554     *
3555     * @typedef Progress
3556     * @syscap SystemCapability.Request.FileTransferAgent
3557     * @crossplatform
3558     * @atomicservice
3559     * @since 11
3560     */
3561    interface Progress {
3562      /**
3563       * The current state of the task.
3564       *
3565       * @type { State }
3566       * @readonly
3567       * @syscap SystemCapability.Request.FileTransferAgent
3568       * @since 10
3569       */
3570      /**
3571       * The current state of the task.
3572       *
3573       * @type { State }
3574       * @readonly
3575       * @syscap SystemCapability.Request.FileTransferAgent
3576       * @crossplatform
3577       * @atomicservice
3578       * @since 11
3579       */
3580      readonly state: State;
3581      /**
3582       * The current processing file index in a task.
3583       *
3584       * @type { number }
3585       * @readonly
3586       * @syscap SystemCapability.Request.FileTransferAgent
3587       * @since 10
3588       */
3589      /**
3590       * The current processing file index in a task.
3591       *
3592       * @type { number }
3593       * @readonly
3594       * @syscap SystemCapability.Request.FileTransferAgent
3595       * @crossplatform
3596       * @atomicservice
3597       * @since 11
3598       */
3599      readonly index: number;
3600      /**
3601       * The processed data size for the current file in a task.
3602       *
3603       * @type { number }
3604       * @readonly
3605       * @syscap SystemCapability.Request.FileTransferAgent
3606       * @since 10
3607       */
3608      /**
3609       * The processed data size for the current file in a task.
3610       *
3611       * @type { number }
3612       * @readonly
3613       * @syscap SystemCapability.Request.FileTransferAgent
3614       * @crossplatform
3615       * @atomicservice
3616       * @since 11
3617       */
3618      readonly processed: number;
3619      /**
3620       * The sizes of files in a task.
3621       *
3622       * @type { Array<number> }
3623       * @readonly
3624       * @syscap SystemCapability.Request.FileTransferAgent
3625       * @since 10
3626       */
3627      /**
3628       * The sizes of files in a task.
3629       *
3630       * @type { Array<number> }
3631       * @readonly
3632       * @syscap SystemCapability.Request.FileTransferAgent
3633       * @crossplatform
3634       * @atomicservice
3635       * @since 11
3636       */
3637      readonly sizes: Array<number>;
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       *
3644       * @type { ?object }
3645       * @readonly
3646       * @syscap SystemCapability.Request.FileTransferAgent
3647       * @since 10
3648       */
3649      /**
3650       * The extras for an interaction.
3651       * Such as headers and body of response from server.
3652       * But when the Content-Disposition header responded, the body will be into the uri of its attachment only, the body here is empty.
3653       * {"headers": {"key": v}, "body": "contents"}.
3654       * The "body" field is not supported in cross-platform scenarios.
3655       *
3656       * @type { ?object }
3657       * @readonly
3658       * @syscap SystemCapability.Request.FileTransferAgent
3659       * @crossplatform
3660       * @atomicservice
3661       * @since 11
3662       */
3663      readonly extras?: object;
3664    }
3665
3666    /**
3667     * Indicates the reason for the failure.
3668     *
3669     * @enum { number }
3670     * @syscap SystemCapability.Request.FileTransferAgent
3671     * @since 10
3672     */
3673    /**
3674     * Indicates the reason for the failure.
3675     *
3676     * @enum { number }
3677     * @syscap SystemCapability.Request.FileTransferAgent
3678     * @crossplatform
3679     * @atomicservice
3680     * @since 11
3681     */
3682    enum Faults {
3683      /**
3684       * Indicates others failure.
3685       *
3686       * @syscap SystemCapability.Request.FileTransferAgent
3687       * @since 10
3688       */
3689      /**
3690       * Indicates others failure.
3691       *
3692       * @syscap SystemCapability.Request.FileTransferAgent
3693       * @crossplatform
3694       * @atomicservice
3695       * @since 11
3696       */
3697      OTHERS = 0xFF,
3698      /**
3699       * Indicates network disconnection.
3700       *
3701       * @syscap SystemCapability.Request.FileTransferAgent
3702       * @since 10
3703       */
3704      /**
3705       * Indicates network disconnection.
3706       *
3707       * @syscap SystemCapability.Request.FileTransferAgent
3708       * @crossplatform
3709       * @atomicservice
3710       * @since 11
3711       */
3712      DISCONNECTED = 0x00,
3713      /**
3714       * Indicates task timeout.
3715       *
3716       * @syscap SystemCapability.Request.FileTransferAgent
3717       * @since 10
3718       */
3719      /**
3720       * Indicates task timeout.
3721       *
3722       * @syscap SystemCapability.Request.FileTransferAgent
3723       * @crossplatform
3724       * @atomicservice
3725       * @since 11
3726       */
3727      TIMEOUT = 0x10,
3728      /**
3729       * Indicates protocol error, such as 5xx response from server.
3730       *
3731       * @syscap SystemCapability.Request.FileTransferAgent
3732       * @since 10
3733       */
3734      /**
3735       * Indicates protocol error, such as 5xx response from server.
3736       *
3737       * @syscap SystemCapability.Request.FileTransferAgent
3738       * @crossplatform
3739       * @atomicservice
3740       * @since 11
3741       */
3742      PROTOCOL = 0x20,
3743      /**
3744       * Indicates parameter error, such as url format error.
3745       *
3746       * @syscap SystemCapability.Request.FileTransferAgent
3747       * @crossplatform
3748       * @atomicservice
3749       * @since 12
3750       */
3751      PARAM = 0x30,
3752      /**
3753       * Indicates filesystem io error, such as open/seek/read/write/close.
3754       *
3755       * @syscap SystemCapability.Request.FileTransferAgent
3756       * @since 10
3757       */
3758      /**
3759       * Indicates filesystem io error, such as open/seek/read/write/close.
3760       *
3761       * @syscap SystemCapability.Request.FileTransferAgent
3762       * @crossplatform
3763       * @atomicservice
3764       * @since 11
3765       */
3766      FSIO = 0x40,
3767      /**
3768       * Indicates DNS resolution error.
3769       *
3770       * @syscap SystemCapability.Request.FileTransferAgent
3771       * @crossplatform
3772       * @atomicservice
3773       * @since 12
3774       */
3775      DNS = 0x50,
3776      /**
3777       * Indicates TCP connection error.
3778       *
3779       * @syscap SystemCapability.Request.FileTransferAgent
3780       * @crossplatform
3781       * @atomicservice
3782       * @since 12
3783       */
3784      TCP = 0x60,
3785      /**
3786       * Indicates SSL connection error, such as a certificate error or certificate verification failure.
3787       *
3788       * @syscap SystemCapability.Request.FileTransferAgent
3789       * @crossplatform
3790       * @atomicservice
3791       * @since 12
3792       */
3793      SSL = 0x70,
3794      /**
3795       * Indicates redirect error.
3796       *
3797       * @syscap SystemCapability.Request.FileTransferAgent
3798       * @crossplatform
3799       * @atomicservice
3800       * @since 12
3801       */
3802      REDIRECT = 0x80
3803    }
3804
3805    /**
3806     * The filter data structure.
3807     * Used for search, given fields works as **LOGICAL AND**.
3808     * Invalid value may cause a parameter error.
3809     *
3810     * @typedef Filter
3811     * @syscap SystemCapability.Request.FileTransferAgent
3812     * @since 10
3813     */
3814    /**
3815     * The filter data structure.
3816     * Used for search, given fields works as **LOGICAL AND**.
3817     * Invalid value may cause a parameter error.
3818     *
3819     * @typedef Filter
3820     * @syscap SystemCapability.Request.FileTransferAgent
3821     * @crossplatform
3822     * @since 11
3823     */
3824    interface Filter {
3825      /**
3826       * Specify the package name of an application.
3827       * Only for advanced search, common search will be fixed to the caller.
3828       * A "*" means any bundle.
3829       *
3830       * @type { ?string }
3831       * @syscap SystemCapability.Request.FileTransferAgent
3832       * @systemapi Hide this for inner system use.
3833       * @since 10
3834       */
3835      bundle?: string;
3836      /**
3837       * Specify the end Unix timestamp.
3838       * The default is the moment of calling.
3839       *
3840       * @type { ?number }
3841       * @syscap SystemCapability.Request.FileTransferAgent
3842       * @since 10
3843       */
3844      /**
3845       * Specify the end Unix timestamp.
3846       * The default is the moment of calling.
3847       *
3848       * @type { ?number }
3849       * @syscap SystemCapability.Request.FileTransferAgent
3850       * @crossplatform
3851       * @since 11
3852       */
3853      before?: number;
3854      /**
3855       * Specify the start Unix timestamp.
3856       * The default is "`before` - 24 hours".
3857       *
3858       * @type { ?number }
3859       * @syscap SystemCapability.Request.FileTransferAgent
3860       * @since 10
3861       */
3862      /**
3863       * Specify the start Unix timestamp.
3864       * The default is "`before` - 24 hours".
3865       *
3866       * @type { ?number }
3867       * @syscap SystemCapability.Request.FileTransferAgent
3868       * @crossplatform
3869       * @since 11
3870       */
3871      after?: number;
3872      /**
3873       * Specify the state of tasks.
3874       * The default is any state.
3875       *
3876       * @type { ?State }
3877       * @syscap SystemCapability.Request.FileTransferAgent
3878       * @since 10
3879       */
3880      /**
3881       * Specify the state of tasks.
3882       * The default is any state.
3883       *
3884       * @type { ?State }
3885       * @syscap SystemCapability.Request.FileTransferAgent
3886       * @crossplatform
3887       * @since 11
3888       */
3889      state?: State;
3890      /**
3891       * Specify the action of tasks, "upload" or "download", case insensitive.
3892       * The default is upload and download.
3893       *
3894       * @type { ?Action }
3895       * @syscap SystemCapability.Request.FileTransferAgent
3896       * @since 10
3897       */
3898      /**
3899       * Specify the action of tasks, "upload" or "download", case insensitive.
3900       * The default is upload and download.
3901       *
3902       * @type { ?Action }
3903       * @syscap SystemCapability.Request.FileTransferAgent
3904       * @crossplatform
3905       * @since 11
3906       */
3907      action?: Action;
3908      /**
3909       * Specify task's mode.
3910       * The default is frontend and background.
3911       *
3912       * @type { ?Mode }
3913       * @syscap SystemCapability.Request.FileTransferAgent
3914       * @since 10
3915       */
3916      /**
3917       * Specify task's mode.
3918       * The default is FOREGROUND and BACKGROUND.
3919       *
3920       * @type { ?Mode }
3921       * @syscap SystemCapability.Request.FileTransferAgent
3922       * @crossplatform
3923       * @since 11
3924       */
3925      mode?: Mode;
3926    }
3927
3928    /**
3929     * The task information data structure for query results.
3930     * Provides common query and advanced query, visible range of fields is different.
3931     *
3932     * @typedef TaskInfo
3933     * @syscap SystemCapability.Request.FileTransferAgent
3934     * @since 10
3935     */
3936    /**
3937     * The task information data structure for query results.
3938     * Provides common query and advanced query, visible range of fields is different.
3939     *
3940     * @typedef TaskInfo
3941     * @syscap SystemCapability.Request.FileTransferAgent
3942     * @crossplatform
3943     * @since 11
3944     */
3945    interface TaskInfo {
3946      /**
3947       * The UID of an application.
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 uid?: string;
3957      /**
3958       * The bundle name.
3959       * For system query only.
3960       *
3961       * @type { ?string }
3962       * @readonly
3963       * @syscap SystemCapability.Request.FileTransferAgent
3964       * @systemapi Hide this for inner system use.
3965       * @since 10
3966       */
3967      readonly bundle?: string;
3968      /**
3969       * The path to save the downloaded file.
3970       *
3971       * @type { ?string }
3972       * @syscap SystemCapability.Request.FileTransferAgent
3973       * @since 10
3974       */
3975      /**
3976       * The path to save the downloaded file.
3977       *
3978       * @type { ?string }
3979       * @readonly
3980       * @syscap SystemCapability.Request.FileTransferAgent
3981       * @crossplatform
3982       * @since 11
3983       */
3984      readonly saveas?: string;
3985      /**
3986       * The url of a task.
3987       * For `${ show }` and `${ touch }`.
3988       * It is empty string in `${ query }`.
3989       *
3990       * @type { ?string }
3991       * @readonly
3992       * @syscap SystemCapability.Request.FileTransferAgent
3993       * @since 10
3994       */
3995      /**
3996       * The url of a task.
3997       * For `${ show }` and `${ touch }`.
3998       *
3999       * @type { ?string }
4000       * @readonly
4001       * @syscap SystemCapability.Request.FileTransferAgent
4002       * @crossplatform
4003       * @since 11
4004       */
4005      readonly url?: string;
4006      /**
4007       * The arguments.
4008       * For `${ show }` and `${ touch }`.
4009       * It is empty string in `${ query }`.
4010       *
4011       * @type { ?(string | Array<FormItem>) }
4012       * @syscap SystemCapability.Request.FileTransferAgent
4013       * @since 10
4014       */
4015      /**
4016       * The arguments.
4017       * For `${ show }` and `${ touch }`.
4018       *
4019       * @type { ?(string | Array<FormItem>) }
4020       * @readonly
4021       * @syscap SystemCapability.Request.FileTransferAgent
4022       * @crossplatform
4023       * @since 11
4024       */
4025      readonly data?: string | Array<FormItem>;
4026      /**
4027       * The task id.
4028       *
4029       * @type { string }
4030       * @readonly
4031       * @syscap SystemCapability.Request.FileTransferAgent
4032       * @since 10
4033       */
4034      /**
4035       * The task id.
4036       *
4037       * @type { string }
4038       * @readonly
4039       * @syscap SystemCapability.Request.FileTransferAgent
4040       * @crossplatform
4041       * @since 11
4042       */
4043      readonly tid: string;
4044      /**
4045       * The task title.
4046       *
4047       * @type { string }
4048       * @readonly
4049       * @syscap SystemCapability.Request.FileTransferAgent
4050       * @since 10
4051       */
4052      /**
4053       * The task title.
4054       *
4055       * @type { string }
4056       * @readonly
4057       * @syscap SystemCapability.Request.FileTransferAgent
4058       * @crossplatform
4059       * @since 11
4060       */
4061      readonly title: string;
4062      /**
4063       * The task details.
4064       *
4065       * @type { string }
4066       * @readonly
4067       * @syscap SystemCapability.Request.FileTransferAgent
4068       * @since 10
4069       */
4070      /**
4071       * The task details.
4072       *
4073       * @type { string }
4074       * @readonly
4075       * @syscap SystemCapability.Request.FileTransferAgent
4076       * @crossplatform
4077       * @since 11
4078       */
4079      readonly description: string;
4080      /**
4081       * The task action.
4082       *
4083       * @type { Action }
4084       * @readonly
4085       * @syscap SystemCapability.Request.FileTransferAgent
4086       * @since 10
4087       */
4088      /**
4089       * The task action.
4090       *
4091       * @type { Action }
4092       * @readonly
4093       * @syscap SystemCapability.Request.FileTransferAgent
4094       * @crossplatform
4095       * @since 11
4096       */
4097      readonly action: Action;
4098      /**
4099       * Specify task mode.
4100       * The default is frontend and background.
4101       *
4102       * @type { Mode }
4103       * @syscap SystemCapability.Request.FileTransferAgent
4104       * @since 10
4105       */
4106      /**
4107       * Specify task mode.
4108       * The default is frontend.
4109       *
4110       * @type { Mode }
4111       * @readonly
4112       * @syscap SystemCapability.Request.FileTransferAgent
4113       * @crossplatform
4114       * @since 11
4115       */
4116      readonly mode: Mode;
4117      /**
4118       * The priority of this task.
4119       * Front-end tasks have higher priority than back-end tasks.
4120       * In tasks of the same mode, the smaller the number, the higher the priority.
4121       * The default is 0.
4122       *
4123       * @type { number }
4124       * @readonly
4125       * @syscap SystemCapability.Request.FileTransferAgent
4126       * @since 11
4127       */
4128      readonly priority: number;
4129      /**
4130       * The MIME type in the configuration of the task.
4131       *
4132       * @type { string }
4133       * @readonly
4134       * @syscap SystemCapability.Request.FileTransferAgent
4135       * @since 10
4136       */
4137      /**
4138       * The MIME type in the configuration of the task.
4139       *
4140       * @type { string }
4141       * @readonly
4142       * @syscap SystemCapability.Request.FileTransferAgent
4143       * @crossplatform
4144       * @since 11
4145       */
4146      readonly mimeType: string;
4147      /**
4148       * An instance of `Progress` for a task.
4149       *
4150       * @type { Progress }
4151       * @readonly
4152       * @syscap SystemCapability.Request.FileTransferAgent
4153       * @since 10
4154       */
4155      /**
4156       * An instance of `Progress` for a task.
4157       *
4158       * @type { Progress }
4159       * @readonly
4160       * @syscap SystemCapability.Request.FileTransferAgent
4161       * @crossplatform
4162       * @since 11
4163       */
4164      readonly progress: Progress;
4165      /**
4166       * The progress notification policy of a background task.
4167       *
4168       * @type { boolean }
4169       * @readonly
4170       * @syscap SystemCapability.Request.FileTransferAgent
4171       * @since 10
4172       */
4173      readonly gauge: boolean;
4174      /**
4175       * The creating date and time of a task in Unix timestamp.
4176       * It is generated by system of current device.
4177       *
4178       * @type { number }
4179       * @readonly
4180       * @syscap SystemCapability.Request.FileTransferAgent
4181       * @since 10
4182       */
4183      /**
4184       * The creating 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       * @crossplatform
4191       * @since 11
4192       */
4193      readonly ctime: number;
4194      /**
4195       * The modified date and time of a task in Unix timestamp.
4196       * It is generated by system of current device.
4197       *
4198       * @type { number }
4199       * @readonly
4200       * @syscap SystemCapability.Request.FileTransferAgent
4201       * @since 10
4202       */
4203      /**
4204       * The modified date and time of a task in Unix timestamp.
4205       * It is generated by system of current device.
4206       *
4207       * @type { number }
4208       * @readonly
4209       * @syscap SystemCapability.Request.FileTransferAgent
4210       * @crossplatform
4211       * @since 11
4212       */
4213      readonly mtime: number;
4214      /**
4215       * The retry switch of a task.
4216       * Just for background, frontend always disabled.
4217       *
4218       * @type { boolean }
4219       * @readonly
4220       * @syscap SystemCapability.Request.FileTransferAgent
4221       * @since 10
4222       */
4223      readonly retry: boolean;
4224      /**
4225       * The tried times of a task.
4226       *
4227       * @type { number }
4228       * @readonly
4229       * @syscap SystemCapability.Request.FileTransferAgent
4230       * @since 10
4231       */
4232      readonly tries: number;
4233      /**
4234       * The faults case of a task.
4235       *
4236       * @type { Faults }
4237       * @readonly
4238       * @syscap SystemCapability.Request.FileTransferAgent
4239       * @since 10
4240       */
4241      /**
4242       * The faults case of a task.
4243       *
4244       * @type { Faults }
4245       * @readonly
4246       * @syscap SystemCapability.Request.FileTransferAgent
4247       * @crossplatform
4248       * @since 11
4249       */
4250      readonly faults: Faults;
4251      /**
4252       * The reason of a waiting/failed/stopped/paused task.
4253       *
4254       * @type { string }
4255       * @readonly
4256       * @syscap SystemCapability.Request.FileTransferAgent
4257       * @since 10
4258       */
4259      /**
4260       * The reason of a waiting/failed/stopped/paused task.
4261       *
4262       * @type { string }
4263       * @readonly
4264       * @syscap SystemCapability.Request.FileTransferAgent
4265       * @crossplatform
4266       * @since 11
4267       */
4268      readonly reason: string;
4269      /**
4270       * The extras of a task.
4271       * For background, the last response from server.
4272       * For frontend, nothing now.
4273       *
4274       * @type { ?object }
4275       * @readonly
4276       * @syscap SystemCapability.Request.FileTransferAgent
4277       * @since 10
4278       */
4279      /**
4280       * The extras of a task.
4281       * For frontend, nothing now.
4282       *
4283       * @type { ?object }
4284       * @readonly
4285       * @syscap SystemCapability.Request.FileTransferAgent
4286       * @crossplatform
4287       * @since 11
4288       */
4289      readonly extras?: object;
4290    }
4291
4292    /**
4293     * The HTTP response.
4294     *
4295     * @interface HttpResponse
4296     * @syscap SystemCapability.Request.FileTransferAgent
4297     * @atomicservice
4298     * @since 12
4299     */
4300    interface HttpResponse {
4301      /**
4302       * The version of the HTTP response.
4303       *
4304       * @type { string }
4305       * @readonly
4306       * @syscap SystemCapability.Request.FileTransferAgent
4307       * @atomicservice
4308       * @since 12
4309       */
4310      readonly version: string,
4311      /**
4312       * The status code of the HTTP response.
4313       *
4314       * @type { number }
4315       * @readonly
4316       * @syscap SystemCapability.Request.FileTransferAgent
4317       * @atomicservice
4318       * @since 12
4319       */
4320      readonly statusCode: number,
4321      /**
4322       * The reason of the HTTP response.
4323       *
4324       * @type { string }
4325       * @readonly
4326       * @syscap SystemCapability.Request.FileTransferAgent
4327       * @atomicservice
4328       * @since 12
4329       */
4330      readonly reason: string,
4331      /**
4332       * The headers of the HTTP response.
4333       *
4334       * @type { Map<string, Array<string>> }
4335       * @readonly
4336       * @syscap SystemCapability.Request.FileTransferAgent
4337       * @atomicservice
4338       * @since 12
4339       */
4340      readonly headers: Map<string, Array<string>>,
4341    }
4342
4343    /**
4344     * The task entry.
4345     * New task' status is "initialized" and enqueue.
4346     * Can `start` a initialized task.
4347     * Can `pause` a waiting/running/retrying background task.
4348     * Can `resume` a paused background task.
4349     * Can `stop` a running/waiting/retrying task and dequeue it.
4350     *
4351     * @typedef Task
4352     * @syscap SystemCapability.Request.FileTransferAgent
4353     * @since 10
4354     */
4355    /**
4356     * The task entry.
4357     * New task' status is "initialized" and enqueue.
4358     * Can `start` a initialized task.
4359     * Can `pause` a waiting/running/retrying background task.
4360     * Can `resume` a paused background task.
4361     * Can `stop` a running/waiting/retrying task and dequeue it.
4362     *
4363     * @typedef Task
4364     * @syscap SystemCapability.Request.FileTransferAgent
4365     * @crossplatform
4366     * @atomicservice
4367     * @since 11
4368     */
4369    interface Task {
4370      /**
4371       * The task id, unique on system.
4372       * Generated automatically by system.
4373       *
4374       * @type { string }
4375       * @readonly
4376       * @syscap SystemCapability.Request.FileTransferAgent
4377       * @since 10
4378       */
4379      /**
4380       * The task id, unique on system.
4381       * Generated automatically by system.
4382       *
4383       * @type { string }
4384       * @readonly
4385       * @syscap SystemCapability.Request.FileTransferAgent
4386       * @crossplatform
4387       * @atomicservice
4388       * @since 11
4389       */
4390      readonly tid: string;
4391      /**
4392       * The configurations for the task.
4393       *
4394       * @type { Config }
4395       * @syscap SystemCapability.Request.FileTransferAgent
4396       * @since 10
4397       */
4398      /**
4399       * The configurations for the task.
4400       *
4401       * @type { Config }
4402       * @syscap SystemCapability.Request.FileTransferAgent
4403       * @crossplatform
4404       * @atomicservice
4405       * @since 11
4406       */
4407      config: Config;
4408      /**
4409       * Enable the specified callback for a frontend task.
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       * @throws { BusinessError } 21900005 - task mode error.
4416       * @syscap SystemCapability.Request.FileTransferAgent
4417       * @since 10
4418       */
4419      /**
4420       * Enables the specified callback.
4421       *
4422       * @param { 'progress' } event - event types.
4423       * @param { function } callback - callback function with a `Progress` argument.
4424       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4425       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4426       * @syscap SystemCapability.Request.FileTransferAgent
4427       * @crossplatform
4428       * @atomicservice
4429       * @since 11
4430       */
4431      on(event: 'progress', callback: (progress: Progress) => void): void;
4432      /**
4433       * Disable the specified callback for a frontend task.
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       * @throws { BusinessError } 21900005 - task mode error.
4440       * @syscap SystemCapability.Request.FileTransferAgent
4441       * @since 10
4442       */
4443      /**
4444       * Disables the specified callback.
4445       *
4446       * @param { 'progress' } event - event types.
4447       * @param { function } callback - callback function with a `Progress` argument.
4448       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4449       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4450       * @syscap SystemCapability.Request.FileTransferAgent
4451       * @crossplatform
4452       * @atomicservice
4453       * @since 11
4454       */
4455      off(event: 'progress', callback?: (progress: Progress) => void): void;
4456      /**
4457       * Enable the specified callback for a frontend task.
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       * @throws { BusinessError } 21900005 - task mode error.
4464       * @syscap SystemCapability.Request.FileTransferAgent
4465       * @since 10
4466       */
4467      /**
4468       * Enables the specified callback.
4469       *
4470       * @param { 'completed' } event - event types.
4471       * @param { function } callback - callback function with a `Progress` argument.
4472       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4473       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4474       * @syscap SystemCapability.Request.FileTransferAgent
4475       * @crossplatform
4476       * @atomicservice
4477       * @since 11
4478       */
4479      on(event: 'completed', callback: (progress: Progress) => void): void;
4480      /**
4481       * Disable the specified callback for a frontend task.
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       * @throws { BusinessError } 21900005 - task mode error.
4488       * @syscap SystemCapability.Request.FileTransferAgent
4489       * @since 10
4490       */
4491      /**
4492       * Disables the specified callback.
4493       *
4494       * @param { 'completed' } event - event types.
4495       * @param { function } callback - callback function with a `Progress` argument.
4496       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4497       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4498       * @syscap SystemCapability.Request.FileTransferAgent
4499       * @crossplatform
4500       * @atomicservice
4501       * @since 11
4502       */
4503      off(event: 'completed', callback?: (progress: Progress) => void): void;
4504      /**
4505       * Enable the specified callback for a frontend task.
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       * @throws { BusinessError } 21900005 - task mode error.
4512       * @syscap SystemCapability.Request.FileTransferAgent
4513       * @since 10
4514       */
4515      /**
4516       * Enables the specified callback.
4517       *
4518       * @param { 'failed' } event - event types.
4519       * @param { function } callback - callback function with a `Progress` argument.
4520       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4521       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4522       * @syscap SystemCapability.Request.FileTransferAgent
4523       * @crossplatform
4524       * @atomicservice
4525       * @since 11
4526       */
4527      on(event: 'failed', callback: (progress: Progress) => void): void;
4528      /**
4529       * Disable the specified callback for a frontend task.
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       * @throws { BusinessError } 21900005 - task mode error.
4536       * @syscap SystemCapability.Request.FileTransferAgent
4537       * @since 10
4538       */
4539      /**
4540       * Disables the specified callback.
4541       *
4542       * @param { 'failed' } event - event types.
4543       * @param { function } callback - callback function with a `Progress` argument.
4544       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4545       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4546       * @syscap SystemCapability.Request.FileTransferAgent
4547       * @crossplatform
4548       * @atomicservice
4549       * @since 11
4550       */
4551      off(event: 'failed', callback?: (progress: Progress) => void): void;
4552      /**
4553       * Enables 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      on(event: 'pause', callback: (progress: Progress) => void): void;
4563      /**
4564       * Disables the specified callback.
4565       *
4566       * @param { 'pause' } 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      off(event: 'pause', callback?: (progress: Progress) => void): void;
4574      /**
4575       * Enables 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      on(event: 'resume', callback: (progress: Progress) => void): void;
4585      /**
4586       * Disables the specified callback.
4587       *
4588       * @param { 'resume' } 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      off(event: 'resume', callback?: (progress: Progress) => void): void;
4596      /**
4597       * Enables 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      on(event: 'remove', callback: (progress: Progress) => void): void;
4607      /**
4608       * Disables the specified callback.
4609       *
4610       * @param { 'remove' } event - event types.
4611       * @param { function } callback - callback function with a `Progress` 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       * @since 11
4616       */
4617      off(event: 'remove', callback?: (progress: Progress) => void): void;
4618      /**
4619       * Enables the response callback.
4620       *
4621       * @param { 'response' } event - event types.
4622       * @param { Callback<HttpResponse> } callback - callback function with an `HttpResponse` argument.
4623       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4624       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4625       * @syscap SystemCapability.Request.FileTransferAgent
4626       * @atomicservice
4627       * @since 12
4628       */
4629      on(event: 'response', callback: Callback<HttpResponse>): void;
4630      /**
4631       * Disables the response callback.
4632       *
4633       * @param { 'response' } event - event types.
4634       * @param { Callback<HttpResponse> } callback - callback function with an `HttpResponse` argument.
4635       * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Missing mandatory parameters.
4636       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4637       * @syscap SystemCapability.Request.FileTransferAgent
4638       * @atomicservice
4639       * @since 12
4640       */
4641      off(event: 'response', callback?: Callback<HttpResponse>): void;
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       * @since 10
4652       */
4653      /**
4654       * Starts the task.
4655       *
4656       * @permission ohos.permission.INTERNET
4657       * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result.
4658       * @throws { BusinessError } 201 - Permission denied.
4659       * @throws { BusinessError } 13400003 - task service ability error.
4660       * @throws { BusinessError } 21900007 - task state error.
4661       * @syscap SystemCapability.Request.FileTransferAgent
4662       * @crossplatform
4663       * @atomicservice
4664       * @since 11
4665       */
4666      /**
4667       * Starts the task. The following tasks can be started:
4668       * 1. Tasks just created.
4669       * 2. Download tasks that are stopped or become FAILED.
4670       *
4671       * @permission ohos.permission.INTERNET
4672       * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result.
4673       * @throws { BusinessError } 201 - Permission denied.
4674       * @throws { BusinessError } 13400003 - task service ability error.
4675       * @throws { BusinessError } 21900007 - task state error.
4676       * @syscap SystemCapability.Request.FileTransferAgent
4677       * @crossplatform
4678       * @atomicservice
4679       * @since 12
4680       */
4681      start(callback: AsyncCallback<void>): void;
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       * @since 10
4692       */
4693      /**
4694       * Starts the task.
4695       *
4696       * @permission ohos.permission.INTERNET
4697       * @returns { Promise<void> } the promise returned by the function.
4698       * @throws { BusinessError } 201 - Permission denied.
4699       * @throws { BusinessError } 13400003 - task service ability error.
4700       * @throws { BusinessError } 21900007 - task state error.
4701       * @syscap SystemCapability.Request.FileTransferAgent
4702       * @crossplatform
4703       * @atomicservice
4704       * @since 11
4705       */
4706      /**
4707       * Starts the task. The following tasks can be started:
4708       * 1. Tasks just created.
4709       * 2. Download tasks that are stopped or become FAILED.
4710       *
4711       * @permission ohos.permission.INTERNET
4712       * @returns { Promise<void> } the promise returned by the function.
4713       * @throws { BusinessError } 201 - Permission denied.
4714       * @throws { BusinessError } 13400003 - task service ability error.
4715       * @throws { BusinessError } 21900007 - task state error.
4716       * @syscap SystemCapability.Request.FileTransferAgent
4717       * @crossplatform
4718       * @atomicservice
4719       * @since 12
4720       */
4721      start(): Promise<void>;
4722      /**
4723       * Pauses the background task.
4724       *
4725       * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result.
4726       * @throws { BusinessError } 13400003 - task service ability error.
4727       * @throws { BusinessError } 21900005 - task mode error.
4728       * @throws { BusinessError } 21900007 - task state error.
4729       * @syscap SystemCapability.Request.FileTransferAgent
4730       * @since 10
4731       */
4732      /**
4733       * Pauses the task.
4734       *
4735       * @param { AsyncCallback<void> } callback - callback function with a boolean argument indicating the calling result.
4736       * @throws { BusinessError } 13400003 - task service ability error.
4737       * @throws { BusinessError } 21900007 - task state error.
4738       * @syscap SystemCapability.Request.FileTransferAgent
4739       * @since 11
4740       */
4741      pause(callback: AsyncCallback<void>): void;
4742      /**
4743       * Pauses the background task.
4744       *
4745       * @returns { Promise<void> } the promise returned by the function.
4746       * @throws { BusinessError } 13400003 - task service ability error.
4747       * @throws { BusinessError } 21900005 - task mode error.
4748       * @throws { BusinessError } 21900007 - task state error.
4749       * @syscap SystemCapability.Request.FileTransferAgent
4750       * @since 10
4751       */
4752      /**
4753       * Pauses the task.
4754       *
4755       * @returns { Promise<void> } the promise returned by the function.
4756       * @throws { BusinessError } 13400003 - task service ability error.
4757       * @throws { BusinessError } 21900007 - task state error.
4758       * @syscap SystemCapability.Request.FileTransferAgent
4759       * @since 11
4760       */
4761      pause(): Promise<void>;
4762      /**
4763       * Resumes the background task.
4764       *
4765       * @permission ohos.permission.INTERNET
4766       * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result.
4767       * @throws { BusinessError } 201 - Permission denied.
4768       * @throws { BusinessError } 13400003 - task service ability error.
4769       * @throws { BusinessError } 21900005 - task mode error.
4770       * @throws { BusinessError } 21900007 - task state error.
4771       * @syscap SystemCapability.Request.FileTransferAgent
4772       * @since 10
4773       */
4774      /**
4775       * Resumes the task.
4776       *
4777       * @permission ohos.permission.INTERNET
4778       * @param { AsyncCallback<void> } callback - callback function with a boolean argument indicating the calling result.
4779       * @throws { BusinessError } 201 - Permission denied.
4780       * @throws { BusinessError } 13400003 - task service ability error.
4781       * @throws { BusinessError } 21900007 - task state error.
4782       * @syscap SystemCapability.Request.FileTransferAgent
4783       * @since 11
4784       */
4785      resume(callback: AsyncCallback<void>): void;
4786      /**
4787       * Resumes the background task.
4788       *
4789       * @permission ohos.permission.INTERNET
4790       * @returns { Promise<void> } the promise returned by the function.
4791       * @throws { BusinessError } 201 - Permission denied.
4792       * @throws { BusinessError } 13400003 - task service ability error.
4793       * @throws { BusinessError } 21900005 - task mode error.
4794       * @throws { BusinessError } 21900007 - task state error.
4795       * @syscap SystemCapability.Request.FileTransferAgent
4796       * @since 10
4797       */
4798      /**
4799       * Resumes the task.
4800       *
4801       * @permission ohos.permission.INTERNET
4802       * @returns { Promise<void> } the promise returned by the function.
4803       * @throws { BusinessError } 201 - Permission denied.
4804       * @throws { BusinessError } 13400003 - task service ability error.
4805       * @throws { BusinessError } 21900007 - task state error.
4806       * @syscap SystemCapability.Request.FileTransferAgent
4807       * @since 11
4808       */
4809      resume(): Promise<void>;
4810      /**
4811       * Stops the task.
4812       *
4813       * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result.
4814       * @throws { BusinessError } 13400003 - task service ability error.
4815       * @throws { BusinessError } 21900007 - task state error.
4816       * @syscap SystemCapability.Request.FileTransferAgent
4817       * @since 10
4818       */
4819      /**
4820       * Stops the task.
4821       *
4822       * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating the calling result.
4823       * @throws { BusinessError } 13400003 - task service ability error.
4824       * @throws { BusinessError } 21900007 - task state error.
4825       * @syscap SystemCapability.Request.FileTransferAgent
4826       * @crossplatform
4827       * @atomicservice
4828       * @since 11
4829       */
4830      stop(callback: AsyncCallback<void>): void;
4831      /**
4832       * Stops the task.
4833       *
4834       * @returns { Promise<void> } the promise returned by the function.
4835       * @throws { BusinessError } 13400003 - task service ability error.
4836       * @throws { BusinessError } 21900007 - task state error.
4837       * @syscap SystemCapability.Request.FileTransferAgent
4838       * @since 10
4839       */
4840      /**
4841       * Stops the task.
4842       *
4843       * @returns { Promise<void> } the promise returned by the function.
4844       * @throws { BusinessError } 13400003 - task service ability error.
4845       * @throws { BusinessError } 21900007 - task state error.
4846       * @syscap SystemCapability.Request.FileTransferAgent
4847       * @crossplatform
4848       * @atomicservice
4849       * @since 11
4850       */
4851      stop(): Promise<void>;
4852      /**
4853       * Sets the maximum transfer speed of the task.
4854       * The minimum value of the speed limit is 16,384 bytes per second(16 KB/s).
4855       *
4856       * @param { number } speed - the maximum transfer speed of the task, in bytes per second.
4857       * @returns { Promise<void> } the promise returned by the function.
4858       * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4859       * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4860       * @throws { BusinessError } 13400003 - task service ability error.
4861       * @syscap SystemCapability.Request.FileTransferAgent
4862       * @since 18
4863       */
4864      setMaxSpeed(speed: number): Promise<void>;
4865    }
4866
4867    /**
4868     * Creates a task for upload or download and enqueue it.
4869     * Only foreground application can create the frontend task.
4870     * It can deal only one frontend task at a time.
4871     * A in processing frontend task will be forced to stop when its application had switched to background.
4872     * A new frontend task will interrupt a existed in processing frontend task.
4873     * The background task is highly recommended.
4874     *
4875     * @permission ohos.permission.INTERNET
4876     * @param { BaseContext } context context of the caller.
4877     * @param { Config } config configurations for a task.
4878     * @param { AsyncCallback<Task> } callback indicate the callback function to receive Task.
4879     * @throws { BusinessError } 201 - permission denied.
4880     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4881     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4882     * @throws { BusinessError } 13400001 - file operation error.
4883     * @throws { BusinessError } 13400003 - task service ability error.
4884     * @throws { BusinessError } 21900004 - the application task queue is full.
4885     * @throws { BusinessError } 21900005 - task mode error.
4886     * @syscap SystemCapability.Request.FileTransferAgent
4887     * @since 10
4888     */
4889    /**
4890     * Creates a task for upload or download and enqueue it.
4891     * When an application enters the background, the frontend tasks associated
4892     * with it will gradually be paused until the application returns to the foreground.
4893     *
4894     * @permission ohos.permission.INTERNET
4895     * @param { BaseContext } context context of the caller.
4896     * @param { Config } config configurations for a task.
4897     * @param { AsyncCallback<Task> } callback indicate the callback function to receive Task.
4898     * @throws { BusinessError } 201 - permission denied.
4899     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4900     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4901     * @throws { BusinessError } 13400001 - file operation error.
4902     * @throws { BusinessError } 13400003 - task service ability error.
4903     * @throws { BusinessError } 21900004 - the application task queue is full.
4904     * @throws { BusinessError } 21900005 - task mode error.
4905     * @syscap SystemCapability.Request.FileTransferAgent
4906     * @crossplatform
4907     * @atomicservice
4908     * @since 11
4909     */
4910    function create(context: BaseContext, config: Config, callback: AsyncCallback<Task>): void;
4911
4912    /**
4913     * Creates a task for upload or download and enqueue it.
4914     * Only foreground application can create the frontend task.
4915     * It can deal only one frontend task at a time.
4916     * A in processing frontend task will be forced to stop when its application had switched to background.
4917     * A new frontend task will interrupt a existed in processing frontend task.
4918     * The background task is highly recommended.
4919     *
4920     * @permission ohos.permission.INTERNET
4921     * @param { BaseContext } context context of the caller.
4922     * @param { Config } config configurations for a task.
4923     * @returns { Promise<Task> } the promise returned by the function.
4924     * @throws { BusinessError } 201 - permission denied.
4925     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4926     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4927     * @throws { BusinessError } 13400001 - file operation error.
4928     * @throws { BusinessError } 13400003 - task service ability error.
4929     * @throws { BusinessError } 21900004 - the application task queue is full.
4930     * @throws { BusinessError } 21900005 - task mode error.
4931     * @syscap SystemCapability.Request.FileTransferAgent
4932     * @since 10
4933     */
4934    /**
4935     * Creates a task for upload or download and enqueue it.
4936     * When an application enters the background, the frontend tasks associated.
4937     * with it will gradually be paused until the application returns to the foreground.
4938     *
4939     * @permission ohos.permission.INTERNET
4940     * @param { BaseContext } context context of the caller.
4941     * @param { Config } config configurations for a task.
4942     * @returns { Promise<Task> } the promise returned by the function.
4943     * @throws { BusinessError } 201 - permission denied.
4944     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4945     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4946     * @throws { BusinessError } 13400001 - file operation error.
4947     * @throws { BusinessError } 13400003 - task service ability error.
4948     * @throws { BusinessError } 21900004 - the application task queue is full.
4949     * @throws { BusinessError } 21900005 - task mode error.
4950     * @syscap SystemCapability.Request.FileTransferAgent
4951     * @crossplatform
4952     * @atomicservice
4953     * @since 11
4954     */
4955    function create(context: BaseContext, config: Config): Promise<Task>;
4956
4957    /**
4958     * Gets the task with the specified id.
4959     *
4960     * @param { BaseContext } context - context of the caller.
4961     * @param { string } id - the id of the task.
4962     * @param { string } token - the token of the task, length between 8 and 2048 bytes.
4963     * @returns { Promise<Task> } the promise returned by the function.
4964     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4965     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
4966     * @throws { BusinessError } 13400003 - task service ability error.
4967     * @throws { BusinessError } 21900006 - task not found.
4968     * @syscap SystemCapability.Request.FileTransferAgent
4969     * @since 11
4970     */
4971    function getTask(context: BaseContext, id: string, token?: string): Promise<Task>;
4972
4973    /**
4974     * Removes specified task belongs to the caller.
4975     * The task will be forced to stop if in processing.
4976     *
4977     * @param { string } id the task id.
4978     * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating success or not.
4979     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4980     * <br>2. Incorrect parameter type.
4981     * @throws { BusinessError } 13400003 - task service ability error.
4982     * @throws { BusinessError } 21900006 - task not found.
4983     * @syscap SystemCapability.Request.FileTransferAgent
4984     * @since 10
4985     */
4986    /**
4987     * Removes specified task belongs to the caller.
4988     * The task will be forced to stop if in processing.
4989     *
4990     * @param { string } id the task id.
4991     * @param { AsyncCallback<void> } callback callback function with a boolean argument indicating success or not.
4992     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
4993     * <br>2. Incorrect parameter type.
4994     * @throws { BusinessError } 13400003 - task service ability error.
4995     * @throws { BusinessError } 21900006 - task not found.
4996     * @syscap SystemCapability.Request.FileTransferAgent
4997     * @crossplatform
4998     * @atomicservice
4999     * @since 11
5000     */
5001    function remove(id: string, callback: AsyncCallback<void>): void;
5002
5003    /**
5004     * Removes specified task belongs to the caller.
5005     * The task will be forced to stop if in processing.
5006     *
5007     * @param { string } id the task id.
5008     * @returns { Promise<void> } the promise returned by the function.
5009     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5010     * <br>2. Incorrect parameter type.
5011     * @throws { BusinessError } 13400003 - task service ability error.
5012     * @throws { BusinessError } 21900006 - task not found.
5013     * @syscap SystemCapability.Request.FileTransferAgent
5014     * @since 10
5015     */
5016    /**
5017     * Removes specified task belongs to the caller.
5018     * The task will be forced to stop if in processing.
5019     *
5020     * @param { string } id the task id.
5021     * @returns { Promise<void> } the promise returned by the function.
5022     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5023     * <br>2. Incorrect parameter type.
5024     * @throws { BusinessError } 13400003 - task service ability error.
5025     * @throws { BusinessError } 21900006 - task not found.
5026     * @syscap SystemCapability.Request.FileTransferAgent
5027     * @crossplatform
5028     * @atomicservice
5029     * @since 11
5030     */
5031    function remove(id: string): Promise<void>;
5032
5033    /**
5034     * Shows specified task details belongs to the caller.
5035     *
5036     * @param { string } id the task id.
5037     * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task.
5038     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5039     * <br>2. Incorrect parameter type.
5040     * @throws { BusinessError } 13400003 - task service ability error.
5041     * @throws { BusinessError } 21900006 - task not found.
5042     * @syscap SystemCapability.Request.FileTransferAgent
5043     * @since 10
5044     */
5045    /**
5046     * Shows specified task details belongs to the caller.
5047     *
5048     * @param { string } id the task id.
5049     * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task.
5050     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5051     * <br>2. Incorrect parameter type.
5052     * @throws { BusinessError } 13400003 - task service ability error.
5053     * @throws { BusinessError } 21900006 - task not found.
5054     * @syscap SystemCapability.Request.FileTransferAgent
5055     * @crossplatform
5056     * @since 11
5057     */
5058    function show(id: string, callback: AsyncCallback<TaskInfo>): void;
5059
5060    /**
5061     * Shows specified task details belongs to the caller.
5062     *
5063     * @param { string } id the task id.
5064     * @returns { Promise<TaskInfo> } the promise returned by the function.
5065     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5066     * <br>2. Incorrect parameter type.
5067     * @throws { BusinessError } 13400003 - task service ability error.
5068     * @throws { BusinessError } 21900006 - task not found.
5069     * @syscap SystemCapability.Request.FileTransferAgent
5070     * @since 10
5071     */
5072    /**
5073     * Shows specified task details belongs to the caller.
5074     *
5075     * @param { string } id the task id.
5076     * @returns { Promise<TaskInfo> } the promise returned by the function.
5077     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5078     * <br>2. Incorrect parameter type.
5079     * @throws { BusinessError } 13400003 - task service ability error.
5080     * @throws { BusinessError } 21900006 - task not found.
5081     * @syscap SystemCapability.Request.FileTransferAgent
5082     * @crossplatform
5083     * @since 11
5084     */
5085    function show(id: string): Promise<TaskInfo>;
5086
5087    /**
5088     * Touches specified task with token.
5089     *
5090     * @param { string } id the task id.
5091     * @param { string } token the in-application isolation key.
5092     * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task.
5093     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5094     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5095     * @throws { BusinessError } 13400003 - task service ability error.
5096     * @throws { BusinessError } 21900006 - task not found.
5097     * @syscap SystemCapability.Request.FileTransferAgent
5098     * @since 10
5099     */
5100    /**
5101     * Touches specified task with token.
5102     *
5103     * @param { string } id the task id.
5104     * @param { string } token the in-application isolation key, length between 8 and 2048 bytes.
5105     * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task.
5106     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5107     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5108     * @throws { BusinessError } 13400003 - task service ability error.
5109     * @throws { BusinessError } 21900006 - task not found.
5110     * @syscap SystemCapability.Request.FileTransferAgent
5111     * @crossplatform
5112     * @since 11
5113     */
5114    function touch(id: string, token: string, callback: AsyncCallback<TaskInfo>): void;
5115
5116    /**
5117     * Touches specified task with token.
5118     *
5119     * @param { string } id the task id.
5120     * @param { string } token the in-application isolation key, length between 8 and 2048 bytes.
5121     * @returns { Promise<TaskInfo> } the promise returned by the function.
5122     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5123     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5124     * @throws { BusinessError } 13400003 - task service ability error.
5125     * @throws { BusinessError } 21900006 - task not found.
5126     * @syscap SystemCapability.Request.FileTransferAgent
5127     * @since 10
5128     */
5129    /**
5130     * Touches specified task with token.
5131     *
5132     * @param { string } id the task id.
5133     * @param { string } token the in-application isolation key, length between 8 and 2048 bytes.
5134     * @returns { Promise<TaskInfo> } the promise returned by the function.
5135     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5136     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5137     * @throws { BusinessError } 13400003 - task service ability error.
5138     * @throws { BusinessError } 21900006 - task not found.
5139     * @syscap SystemCapability.Request.FileTransferAgent
5140     * @crossplatform
5141     * @since 11
5142     */
5143    function touch(id: string, token: string): Promise<TaskInfo>;
5144
5145    /**
5146     * Searches tasks, for system.
5147     *
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 { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter.
5159     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type.
5160     * <br>2. Parameter verification failed.
5161     * @throws { BusinessError } 13400003 - task service ability error.
5162     * @syscap SystemCapability.Request.FileTransferAgent
5163     * @crossplatform
5164     * @since 11
5165     */
5166    function search(callback: AsyncCallback<Array<string>>): void;
5167
5168    /**
5169     * Searches tasks, for system.
5170     *
5171     * @param { Filter } filter an instance of `Filter`.
5172     * @param { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter.
5173     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type.
5174     * <br>2. Parameter verification failed.
5175     * @throws { BusinessError } 13400003 - task service ability error.
5176     * @syscap SystemCapability.Request.FileTransferAgent
5177     * @since 10
5178     */
5179    /**
5180     * Searches tasks, for system.
5181     *
5182     * @param { Filter } filter an instance of `Filter`.
5183     * @param { AsyncCallback<Array<string>> } callback callback function with a `Array<string>` argument contains task ids match filter.
5184     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type.
5185     * <br>2. Parameter verification failed.
5186     * @throws { BusinessError } 13400003 - task service ability error.
5187     * @syscap SystemCapability.Request.FileTransferAgent
5188     * @crossplatform
5189     * @since 11
5190     */
5191    function search(filter: Filter, callback: AsyncCallback<Array<string>>): void;
5192
5193    /**
5194     * Searches tasks, for system.
5195     *
5196     * @param { Filter } filter an instance of `Filter`.
5197     * @returns { Promise<Array<string>> } the promise returned by the function.
5198     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type.
5199     * <br>2. Parameter verification failed.
5200     * @throws { BusinessError } 13400003 - task service ability error.
5201     * @syscap SystemCapability.Request.FileTransferAgent
5202     * @since 10
5203     */
5204    /**
5205     * Searches tasks, for system.
5206     *
5207     * @param { Filter } filter an instance of `Filter`.
5208     * @returns { Promise<Array<string>> } the promise returned by the function.
5209     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter type.
5210     * <br>2. Parameter verification failed.
5211     * @throws { BusinessError } 13400003 - task service ability error.
5212     * @syscap SystemCapability.Request.FileTransferAgent
5213     * @crossplatform
5214     * @since 11
5215     */
5216    function search(filter?: Filter): Promise<Array<string>>;
5217
5218    /**
5219     * Queries specified task details.
5220     *
5221     * @permission ohos.permission.DOWNLOAD_SESSION_MANAGER or ohos.permission.UPLOAD_SESSION_MANAGER
5222     * @param { string } id the task id.
5223     * @param { AsyncCallback<TaskInfo> } callback callback function with a `TaskInfo` argument for informations of the current task.
5224     * @throws { BusinessError } 201 - permission denied.
5225     * @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
5226     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5227     * <br>2. Incorrect parameter type.
5228     * @throws { BusinessError } 13400003 - task service ability error.
5229     * @throws { BusinessError } 21900006 - task not found.
5230     * @syscap SystemCapability.Request.FileTransferAgent
5231     * @systemapi Hide this for inner system use.
5232     * @since 10
5233     */
5234    function query(id: string, callback: AsyncCallback<TaskInfo>): void;
5235
5236    /**
5237     * Queries specified task details.
5238     *
5239     * @permission ohos.permission.DOWNLOAD_SESSION_MANAGER or ohos.permission.UPLOAD_SESSION_MANAGER
5240     * @param { string } id the task id.
5241     * @returns { Promise<TaskInfo> } the promise returned by the function.
5242     * @throws { BusinessError } 201 - permission denied.
5243     * @throws { BusinessError } 202 - permission verification failed, application which is not a system application uses system API.
5244     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5245     * <br>2. Incorrect parameter type.
5246     * @throws { BusinessError } 13400003 - task service ability error.
5247     * @throws { BusinessError } 21900006 - task not found.
5248     * @syscap SystemCapability.Request.FileTransferAgent
5249     * @systemapi Hide this for inner system use.
5250     * @since 10
5251     */
5252    function query(id: string): Promise<TaskInfo>;
5253
5254    /**
5255     * The config of the task group.
5256     *
5257     * @typedef GroupConfig
5258     * @syscap SystemCapability.Request.FileTransferAgent
5259     * @since 15
5260     */
5261    interface GroupConfig {
5262      /**
5263       * Sets display strategy for background task notifications.
5264       * If true, progress, completed, and failed notifications will be displayed.
5265       * If false, only completed or failed notifications will be displayed.
5266       * The default value is false.
5267       *
5268       * @type { ?boolean }
5269       * @syscap SystemCapability.Request.FileTransferAgent
5270       * @since 15
5271       */
5272      gauge?: boolean;
5273      /**
5274       * Customizes the notification of the task group.
5275       *
5276       * @type { Notification }
5277       * @syscap SystemCapability.Request.FileTransferAgent
5278       * @since 15
5279       */
5280      notification: Notification;
5281    }
5282
5283    /**
5284     * Creates a background download task notification group.
5285     *
5286     * @param { GroupConfig } config - config of the group.
5287     * @returns { Promise<string> } the gid of the group.
5288     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5289     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5290     * @throws { BusinessError } 13400003 - task service ability error.
5291     * @syscap SystemCapability.Request.FileTransferAgent
5292     * @since 15
5293     */
5294    function createGroup(config: GroupConfig): Promise<string>;
5295
5296    /**
5297     * Adds a newly created background download task to the target group.
5298     *
5299     * @param { string } gid - the gid of the target group.
5300     * @param { string[] } tids - the tid list of tasks to be attached.
5301     * @returns { Promise<void> } the promise returned by the function.
5302     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5303     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5304     * @throws { BusinessError } 13400003 - task service ability error.
5305     * @throws { BusinessError } 21900005 - task mode error.
5306     * @throws { BusinessError } 21900006 - task not found.
5307     * @throws { BusinessError } 21900007 - task state error.
5308     * @throws { BusinessError } 21900008 - group deleted or not found.
5309     * @syscap SystemCapability.Request.FileTransferAgent
5310     * @since 15
5311     */
5312    function attachGroup(gid: string, tids: string[]): Promise<void>;
5313
5314    /**
5315     * Deletes the target group, no more new tasks can be added to this group.
5316     * If all tasks in this group end, completed or failed notifications will be displayed.
5317     *
5318     * @param { string } gid - the gid of the target group.
5319     * @returns { Promise<void> } the promise returned by the function.
5320     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Missing mandatory parameters.
5321     * <br>2. Incorrect parameter type. 3. Parameter verification failed.
5322     * @throws { BusinessError } 13400003 - task service ability error.
5323     * @throws { BusinessError } 21900008 - group deleted or not found.
5324     * @syscap SystemCapability.Request.FileTransferAgent
5325     * @since 15
5326     */
5327    function deleteGroup(gid: string): Promise<void>;
5328  }
5329}
5330
5331export default request;
5332