How Mega downloads a file?

tuandhq picture tuandhq · Aug 25, 2013 · Viewed 10.5k times · Source

when you download a file from MEGA service, a web page to display a download progress bar will appear. After the bar reaches 100%, your browser will notify users to save the file into a selected folder. I know that Mega use HTML5 FileSystem API to do this (Download files like mega.co.nz ). However, i don't know when the file is completely downloaded into the sandboxed directory, how the browser's instructed to notify users about the download? Would you please answer my question? Thanks in advance.

Answer

roberto picture roberto · Nov 28, 2013

By using either a[download], msSaveOrOpenBlob, or Adobe Flash SWF Filewriter, depending on which method is supported by the browser.

PS: MEGA doesn't always use HTML5 FileSystem API. They have various techniques that they use depending on the browser support. In Firefox 20+, for example, they will store the data temporarily to the IndexedDB storage, before triggering the a[download].