1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | export declare enum NotificationVisibility {
|
3 | Visible = 0,
|
4 | VisibleNotifyCompleted = 1,
|
5 | VisibilityHidden = 2,
|
6 | VisibleNotifyOnlyCompletion = 3
|
7 | }
|
8 | export interface DownloadHttpHeader {
|
9 | header: string;
|
10 | value: string;
|
11 | }
|
12 | export interface DestinationDirectory {
|
13 | dirType: string;
|
14 | subPath: string;
|
15 | }
|
16 | export interface DownloadRequest {
|
17 | /**
|
18 | * Location of the resource to download
|
19 | */
|
20 | uri: string;
|
21 | /**
|
22 | * Set the title of this download, to be displayed in notifications (if enabled).
|
23 | * If no title is given, a default one will be assigned based on the download filename, once the download starts.
|
24 | */
|
25 | title?: string;
|
26 | /**
|
27 | * Set a description of this download, to be displayed in notifications (if enabled)
|
28 | */
|
29 | description?: string;
|
30 | /**
|
31 | * Set the MIME content type of this download. This will override the content type declared in the server's response.
|
32 | */
|
33 | mimeType?: string;
|
34 | /**
|
35 | * Set whether this download should be displayed in the system's Downloads UI. True by default.
|
36 | */
|
37 | visibleInDownloadsUi?: boolean;
|
38 | /**
|
39 | * Control whether a system notification is posted by the download manager while this download is running or when it is completed.
|
40 | */
|
41 | notificationVisibility?: NotificationVisibility;
|
42 | /**
|
43 | * Set the local destination for the downloaded file to a path within the application's external files directory
|
44 | */
|
45 | destinationInExternalFilesDir?: DestinationDirectory;
|
46 | /**
|
47 | * Set the local destination for the downloaded file to a path within the public external storage directory
|
48 | */
|
49 | destinationInExternalPublicDir?: DestinationDirectory;
|
50 | /**
|
51 | * Set the local destination for the downloaded file.
|
52 | * Must be a file URI to a path on external storage, and the calling application must have the WRITE_EXTERNAL_STORAGE permission.
|
53 | */
|
54 | destinationUri?: string;
|
55 | /**
|
56 | * Add an HTTP header to be included with the download request. The header will be added to the end of the list.
|
57 | */
|
58 | headers?: DownloadHttpHeader[];
|
59 | }
|
60 | /**
|
61 | * @name Downloader
|
62 | * @description
|
63 | * This plugin is designed to support downloading files using Android DownloadManager.
|
64 | *
|
65 | *
|
66 | * @usage
|
67 | * ```typescript
|
68 | * import { Downloader } from '@ionic-native/downloader/ngx';
|
69 | *
|
70 | *
|
71 | * constructor(private downloader: Downloader) { }
|
72 | *
|
73 | * ...
|
74 | *
|
75 | * var request: DownloadRequest = {
|
76 | * uri: YOUR_URI,
|
77 | * title: 'MyDownload',
|
78 | * description: '',
|
79 | * mimeType: '',
|
80 | * visibleInDownloadsUi: true,
|
81 | * notificationVisibility: NotificationVisibility.VisibleNotifyCompleted,
|
82 | * destinationInExternalFilesDir: {
|
83 | * dirType: 'Downloads',
|
84 | * subPath: 'MyFile.apk'
|
85 | * }
|
86 | * };
|
87 | *
|
88 | *
|
89 | * this.downloader.download(request)
|
90 | * .then((location: string) => console.log('File downloaded at:'+location))
|
91 | * .catch((error: any) => console.error(error));
|
92 | *
|
93 | * ```
|
94 | * @interfaces
|
95 | * NotificationVisibility
|
96 | * Header
|
97 | * DestinationDirectory
|
98 | * DownloadHttpHeader
|
99 | */
|
100 | export declare class DownloaderOriginal extends IonicNativePlugin {
|
101 | /**
|
102 | * Starts a new download and returns location of the downloaded file on completion
|
103 | * @param request {DownloadRequest}
|
104 | */
|
105 | download(request: DownloadRequest): Promise<string>;
|
106 | }
|
107 |
|
108 | export declare const Downloader: DownloaderOriginal; |
\ | No newline at end of file |