I’m trying to use Tizen download API to download media from a server (images, videos, gifs, etc), and it doesn’t download the file properly. This is the code I used from the tizen docs:
const downloadUrl = 'https://magic-sign.cloud/v4/web/MSlibrary/wi-night-partly-cloudy.jpg';
const downloadFileName = 'wi-night-partly-cloudy.jpg';
var downloadRequest = new tizen.DownloadRequest(downloadUrl, path, downloadFileName, 'ALL', {'Content- Type' : 'image/jpeg'});
tizen.systeminfo.getPropertyValue('NETWORK', function(networkInfo) {
if (networkInfo.networkType === 'NONE') {
console.log(`Network connection is not available.
Download is not possible.`);
downloadRequest = null;
}
});
var listener = {
/* When the download progresses (interval is platform-dependent) */
onprogress: function(id, receivedSize, totalSize) {
console.log('Received with id: ' + id + ', ' + receivedSize + '/' + totalSize);
},
/* When the user pauses the download */
onpaused: function(id) {
console.log('Paused with id: ' + id);
},
/* When the user cancels the download */
oncanceled: function(id) {
console.log('Canceled with id: ' + id);
},
/* When the download is completed */
oncompleted: function(id, fullPath) {
console.log('Completed with id: ' + id + ', full path: ' + fullPath);
},
/* When the download fails */
onfailed: function(id, error) {
console.log('Failed with id: ' + id + ', error name: ' + error.name);
}
};
let downloadId = tizen.download.start(downloadRequest, listener);
tizen.download.getState(downloadId);
var state = tizen.download.getState(downloadId);
console.log(state);
var downloadRequest = tizen.download.getDownloadRequest(downloadId);
console.log(downloadRequest);
var MIMEType = tizen.download.getMIMEType(downloadId);
console.log(MIMEType);
and when I try to console.log the download request before the start method this is what I got:
and this is the download request and the mime type after the start method, Note: that I explicitely set the the content type to image/jpeg:
Also, there is no issue with the download. It keeps saying download complete, and it stores the file in the exact location, but the file is not an image (for this example, I tried to download an image):
I’m trying to use Tizen download API to download media from a server (images, videos, gifs, etc), and it doesn’t download the file properly. This is the file output that being stored to the location:
Note: when I try to get the image from the same URL using the browser or postman it works fine I got the image with the right size and content type.
Have anyone encountered this problem before?