Closed Bug 930657 Opened 11 years ago Closed 11 years ago

[Gaia][System] Download Manager API Design

Categories

(Firefox OS Graveyard :: Gaia::System, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
1.3 Sprint 6 - 12/6

People

(Reporter: aus, Assigned: aus)

References

Details

(Whiteboard: [systemsfe])

Attachments

(1 file)

As part of the download manager work for 1.3 we'll be designing a new Download Manager API.

This API will enable downloads to be triggered from any application.

This API will enable applications to list all active downloads.

This API will enable applications to interact with active and completed downloads.

The API may reuse existing Gecko Download Manager objects.

Basic API proposal from Fabrice (designed a while back):

interface DownloadManager : EventTarget { // ondownloadstart, etc.
  Promise<Download[]> getDownloads();
  ... // other misc functions like clearDone() ?
}

interface Download : EventTarget { // onprogress, onload, etc.
  long size;
  long downloaded;
  DOMString state; // "running", "paused", "canceled"
  DOMString uri;
  void cancel();
  void pause();
  void resume();
}
Attached patch patch 1Splinter Review
This patch makes the changes needed to let downloads end up in the default storage area (either the internal storage or the sdcard) and neither block on a confirmation prompt.
I may understand why a download API is needed for iterating/pausing/resuming/.. downloads, and this is fine.

But can we additionaly bind the html5 download attribute to triggers downloads as well. Then websites/bookmarks will be able to opt-in in a cross-browser compatible way.

For example with the download attribute you can do:
 <a href="foo.pdf" download="save_as_bar.pdf">

This will launch the file foo.pdf and save it as save_as_bar.pdf.
I assume that if someone wants to trigger that with JS directly you can just do an xhr or a bit more ugly:
 var a = document.createElement('a');
 a.href = 'foo.pdf';
 a.download = 'save_as_bar.pdf';
 a.click();

Or something similar.
This is a little bit ugly but at least it should work all over the place, and websites/bookmars/applications will not need to know anything about a special API that will mostly be used to manage downloads.

Does it makes sense or did I missed some dependencies of this bug that was looking to do that?
Vivien, this api is explicitely only about *managing* downloads, not starting them. The usual ways to trigger downloads are supported:
- download attribute,
- content-disposition http header,
- unknown mime type.
Depends on: 934677
Blocks: 936342
No longer blocks: 936342
Depends on: 938023
Whiteboard: [systemsfe]
This is done as far as I know.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.3 Sprint 6 - 12/6
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: