01-08-2014 05:17 AM
I would like the user to click a link with href to external file which would open a browser save as window. Is it possible with webworks for bb10?
I tried to use download for <a> tag but it's not working.
Solved! Go to Solution.
01-08-2014 06:33 AM - edited 01-08-2014 06:36 AM
You can use:
01-08-2014 11:04 AM
If you just add an href it'll redirect your application to that url when the user clicks it.
I'd recommend using a Child Browser, it'll open a new view (with a close button). That way the user never actually has to leave your application.
If the use-case is to download a file from said link then I would use what Miamon mentioned, the fileTransfer API.
01-09-2014 09:07 AM
thanks for replies. I was just wondering why it is not working smth like this <a href="link path" download="filename"> </a>
I try to load an external audio file and the browser starts to play it instead of loading by default. The build in file transfer API doesn't show progress when loading a file. So it is very user unfriendly.
01-13-2014 11:37 AM
It's doesn't work because as you've discovered, the browser will play the file by design.
If the FileTransfer API isn't what you're hoping it was right now then I'd suggest you take a look at XHR. You can get progress events. It sounds like that's what you're going for. Note that it'll be more work than the FileTransfer API as you'll have to manually save the downloaded file blob to the filesystem yourself.
Here's a link to the best XHR2 article ever written, it covers a lot of different use cases: http://www.html5rocks.com/en/tutorials/file/xhr2/