This topic describes how your application can download data from a remote server.
Samsung Smart Signage supports downloading data from a remote server, using the Download API. For example, you can download external subtitles for a video.
To use the Download API, the application has to request permission by adding the following privilege to the "config.xml" file:
<tizen:privilege name='http://tizen.org/privilege/download'></tizen:privilege>
To download data:
Check that downloading is supported using the getCapability()
method of the SystemInfo API:
var downloadPossible = tizen.systeminfo.getCapability('http://tizen.org/feature/download');console.log(downloadPossible);
Create a download request object using the DownloadRequest()
method:
var download_obj = new tizen.DownloadRequest('http://download.tizen.org/tools/README.txt', 'downloads');
Start the download using the start()
method, with the download request object as a parameter:
tizen.download.start(download_obj, { onprogress: function(id, receivedSize, totalSize) { console.log(id); console.log(receivedSize); console.log(totalSize); }, onpaused: function(id) { console.log(id); }, oncanceled: function(id) { console.log(id); }, oncompleted: function(id, fullPath) { console.log(id); console.log(fullPath); }, onfailed: function(id, error) { console.log(id); console.log(JSON.stringify(error)); }});
When downloading is complete, the oncompleted()
event handler fires.