Reimplement downloadItem.getFilename API.
Previously, the suggested file name(Always 'empty') returned by 'download_item->GetSuggestedFilename' is not the same with the default one saved in local disk. The patch reimplement this API allowing it to return the default file name, which is more expected from user.
This commit is contained in:
parent
0861d5d44b
commit
1879392c7b
6 changed files with 25 additions and 16 deletions
|
@ -10,10 +10,10 @@ win.webContents.session.on('will-download', function(event, item, webContents) {
|
|||
// Set the save path, making Electron not to prompt a save dialog.
|
||||
item.setSavePath('/tmp/save.pdf');
|
||||
console.log(item.getMimeType());
|
||||
console.log(item.getSuggestedFilename());
|
||||
console.log(item.getFilename());
|
||||
console.log(item.getTotalBytes());
|
||||
item.on('updated', function() {
|
||||
console.log('Recived bytes: ' + item.getReceivedBytes());
|
||||
console.log('Received bytes: ' + item.getReceivedBytes());
|
||||
});
|
||||
item.on('done', function(e, state) {
|
||||
if (state == "completed") {
|
||||
|
@ -24,7 +24,6 @@ win.webContents.session.on('will-download', function(event, item, webContents) {
|
|||
});
|
||||
```
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### Event: 'updated'
|
||||
|
@ -79,13 +78,13 @@ Returns a `String` represents the mime type.
|
|||
|
||||
Returns a `Boolean` indicates whether the download has user gesture.
|
||||
|
||||
### `downloadItem.getSuggestedFilename()`
|
||||
### `downloadItem.getFilename()`
|
||||
|
||||
Returns a `String` represents the suggested file name of the download file.
|
||||
Returns a `String` represents the file name of the download item.
|
||||
|
||||
**Note:** The suggested file name is not always the same as the actual one saved
|
||||
in local disk. If user changes the file name in a prompted download saving
|
||||
dialog, the actual name of saved file will be different with the suggested one.
|
||||
**Note:** The file name is not always the same as the actual one saved in local
|
||||
disk. If user changes the file name in a prompted download saving dialog, the
|
||||
actual name of saved file will be different.
|
||||
|
||||
### `downloadItem.getTotalBytes()`
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue