Skip to content

browser: creating download manager delegate to handle downloads - #2030

Merged
zcbenz merged 1 commit into
electron:masterfrom
deepak1556:file_download_patch
Jun 23, 2015
Merged

zcbenz merged 1 commit into
electron:masterfrom
deepak1556:file_download_patch

Conversation

@deepak1556

Copy link
Copy Markdown
Member

Fixes #1909

this basic implemetation provides ability to save downloads, the default download directory points to Downloads folder in the respective app. We can provide api around this for users track status of each download by adding observers to this class, it deserves a separate PR. Thoughts ?

@hokein

hokein commented Jun 22, 2015

Copy link
Copy Markdown
Contributor

We may add Download APIs like

downloads.download({url: "", download_dir:"", file_name""}, function(error, downloadId) {})
downloads.pause(downloadId, callback)
downloads.resume(downloadId, callback)
downloads.cancel(downloadId, callback)
downloads.show(downloadId)

// details = {
//   download_id: "",
//   url: "",
//   file_name: "",
//   total_bytes: "",
//   downloaded_bytes:""
// }
downloads.on('changed', function(details) {})

But I wonder it's worthy adding this. Not sure whether it's a desirable feature that most developers need.

@deepak1556

Copy link
Copy Markdown
Member Author

But I wonder it's worthy adding this. Not sure whether it's a desirable feature that most developers need.

Just so they can provide their own UI for download progress, or alteast get notifed of the downloads status.

I am +1 on that api, will wait for others suggestion and get it as a separate PR. Thanks!

@steelbrain

Copy link
Copy Markdown
Contributor

❤️

@steelbrain

Copy link
Copy Markdown
Contributor

and instead of the API @hokein suggested, how about

type Progress = shape(
  TotalBytes => float,
  RecievedBytes => float
)
class Downloads{
  static setSavePath(path: String): void
  static download(path: String[, savePath: String]): Download
}
class Download extends EventEmitter{
  savePath: String
  onComplete(Callback: function(): void): void
  onProgress(Callback: function(Progress): void): void
  onAbort(Callback: function(hadError: bool): void): void
  pause(): void
  cancel()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition should never be true.

@deepak1556
deepak1556 force-pushed the file_download_patch branch from 25c4ac9 to 8f429bc Compare June 23, 2015 12:24
@zcbenz

zcbenz commented Jun 23, 2015

Copy link
Copy Markdown
Contributor

👍

zcbenz added a commit that referenced this pull request Jun 23, 2015
browser: creating download manager delegate to handle downloads
@zcbenz
zcbenz merged commit 93fb70b into electron:master Jun 23, 2015
@kjlaw89 kjlaw89 mentioned this pull request Aug 12, 2015
@afocus

afocus commented Aug 15, 2015

Copy link
Copy Markdown

I am +1 on download api,

@jaredatron

Copy link
Copy Markdown

What do I have to do to get this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants