Closed Bug 1066675 Opened 11 years ago Closed 11 years ago

SystemXHR and DeviceStorage

Categories

(Firefox OS Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 855952

People

(Reporter: bonuspunkt+bugzilla, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0 Build ID: 20140830210550 Steps to reproduce: im trying to download a podcast (140MB) to the device via wifi and store it in the music library ``` var musicStore = navigator.getDeviceStorage('music'); var xhr = new XMLHttpRequest({ mozSystem: true }); xhr.open('GET', 'http://localhost:8888/fs139-rectal-temperature-sensor-location.mp3'); xhr.send(); xhr.addEventListener('load', function() { var blob = new Blob([xhr.responseText], { type: 'audio/mp3'}); console.log('loading done'); var add = musicStore.add(blob); add.onsuccess = function() { console.log('add success'); } add.onerror = function() { console.log('add error'); console.log(arguments); } }); ``` Actual results: in the simulator i get an error Expected results: i don't know if the api is good for that use case. transforming the xhr.responseText to an Blob seems kinda big overhead. maybe we there should be a download task for files that huge or the xhr could stream into the music storage
You should set xhr.responseType = "blob" and then just get your blob from xhr.response. It still may be large though, so you may want to also look at chunking.
Component: Hardware → General
did i miss something or is it currently impossible to write chunked to DeviceStorage
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.