Refactored such that download works from cordova serve