I'm using appgyver steroids (phonegap) and trying to save photos from the camera API to the app filespace so that it is not removed when I re-scan/re-load the app. I'm following the example from the cordova api docs (http://docs.phonegap.com/en/1.5.0/phonegap_file_file.md.html#FileSystem), but I never get a response from
window.requestileSystem(LocalFileSystem.PERSISTENT, ...)
The promise is never resolved/rejected. what am I doing wrong?
# in coffeescript
console.log "1. window.deviceReady. navigator.camera"+JSON.stringify(navigator.camera), null, 10000
_fsDeferred = $q.defer()
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
50000*1024,
(fs)->
console.log "2. window.requestFileSystem, FS= "+JSON.stringify(fs), null, 10000
_fsRoot = fs.root
_fsDeferred.resolve(_fsRoot)
(ev)->
console.log "3. Error: requestFileSystem failed. "+ev.target.error.code, 'danger', 10000
_fsDeferred.reject(ev)
)
_fsDeferred.promise.finally ()->
console.log "4. window.requestFileSystem(), Deferred.promise.finally(), args"+JSON.stringify arguments, 'danger', 10000
i never get to #4, the promise is never resolved.
AppGyver employee here – I created a simplified repro from your code, and it seems to work fine. See repro here.
One error I was getting when working off your code is that JSON.stringify(fs)
was failing because fs
is a cyclic structure and JSON.stringify
cannot serialize them. If you just do console.log(fs)
, you get the filesystem object fine (you might need to do a location.reload()
in Safari Web Inspector to catch stuff that happens on application load).