@@ -37,9 +37,11 @@ win.webContents.session.on('will-download', (event, item, webContents) => {
3737})
3838```
3939
40- ## Events
40+ ## Class: DownloadItem
4141
42- ### Event: 'updated'
42+ ### Instance Events
43+
44+ #### Event: 'updated'
4345
4446Returns:
4547
@@ -53,7 +55,7 @@ The `state` can be one of following:
5355* ` progressing ` - The download is in-progress.
5456* ` interrupted ` - The download has interrupted and can be resumed.
5557
56- ### Event: 'done'
58+ #### Event: 'done'
5759
5860Returns:
5961
@@ -70,86 +72,79 @@ The `state` can be one of following:
7072* ` cancelled ` - The download has been cancelled.
7173* ` interrupted ` - The download has interrupted and can not resume.
7274
73- ## Methods
75+ ### Instance Methods
7476
7577The ` downloadItem ` object has the following methods:
7678
77- ### ` downloadItem.setSavePath(path) `
79+ #### ` downloadItem.setSavePath(path) `
7880
7981* ` path ` String - Set the save file path of the download item.
8082
8183The API is only available in session's ` will-download ` callback function.
8284If user doesn't set the save path via the API, Electron will use the original
8385routine to determine the save path(Usually prompts a save dialog).
8486
85- ### ` downloadItem.getSavePath() `
87+ #### ` downloadItem.getSavePath() `
8688
8789Returns ` String ` - The save path of the download item. This will be either the path
8890set via ` downloadItem.setSavePath(path) ` or the path selected from the shown
8991save dialog.
9092
91- ### ` downloadItem.pause() `
93+ #### ` downloadItem.pause() `
9294
9395Pauses the download.
9496
95- ### ` downloadItem.isPaused() `
97+ #### ` downloadItem.isPaused() `
9698
9799Returns ` Boolean ` - Whether the download is paused.
98100
99- ### ` downloadItem.resume() `
101+ #### ` downloadItem.resume() `
100102
101103Resumes the download that has been paused.
102104
103- ### ` downloadItem.canResume() `
105+ #### ` downloadItem.canResume() `
104106
105107Resumes ` Boolean ` - Whether the download can resume.
106108
107- ### ` downloadItem.cancel() `
109+ #### ` downloadItem.cancel() `
108110
109111Cancels the download operation.
110112
111- ### ` downloadItem.getURL() `
113+ #### ` downloadItem.getURL() `
112114
113115Returns ` String ` - The origin url where the item is downloaded from.
114116
115- ### ` downloadItem.getMimeType() `
117+ #### ` downloadItem.getMimeType() `
116118
117119Returns ` String ` - The files mime type.
118120
119- ### ` downloadItem.hasUserGesture() `
121+ #### ` downloadItem.hasUserGesture() `
120122
121123Returns ` Boolean ` - Whether the download has user gesture.
122124
123- ### ` downloadItem.getFilename() `
125+ #### ` downloadItem.getFilename() `
124126
125127Returns ` String ` - The file name of the download item.
126128
127129** Note:** The file name is not always the same as the actual one saved in local
128130disk. If user changes the file name in a prompted download saving dialog, the
129131actual name of saved file will be different.
130132
131- ### ` downloadItem.getTotalBytes() `
133+ #### ` downloadItem.getTotalBytes() `
132134
133135Returns ` Integer ` - The total size in bytes of the download item.
134136
135137If the size is unknown, it returns 0.
136138
137- ### ` downloadItem.getReceivedBytes() `
139+ #### ` downloadItem.getReceivedBytes() `
138140
139141Returns ` Integer ` - The received bytes of the download item.
140142
141- ### ` downloadItem.getContentDisposition() `
143+ #### ` downloadItem.getContentDisposition() `
142144
143145Returns ` String ` - The Content-Disposition field from the response
144146header.
145147
146- ### ` downloadItem.getState() `
147-
148- Returns ` String ` - The current state.
149-
150- Possible values are:
148+ #### ` downloadItem.getState() `
151149
152- * ` progressing ` - The download is in-progress.
153- * ` completed ` - The download completed successfully.
154- * ` cancelled ` - The download has been cancelled.
155- * ` interrupted ` - The download has interrupted.
150+ Returns ` String ` - The current state. Can be ` progressing ` , ` completed ` , ` cancelled ` or ` interrupted ` .
0 commit comments