aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-06-11 18:06:55 +0100
committerStruan Donald <struan@exo.org.uk>2012-06-11 18:06:55 +0100
commitc7072871db77c6398e7abdc0e1b11fd490bb8081 (patch)
treedc893e2e8f5fc35bfb36b4f898e0cad3f258b313 /www/js
parentcac7b01b644ff1cc2f7c76afc920cb8f5149be82 (diff)
FileTransfer does not seem to URI decode things which breaks JSON parsing
Also need to set chunkedMode to false otherwise upload fails on android
Diffstat (limited to 'www/js')
-rw-r--r--www/js/mobile.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/www/js/mobile.js b/www/js/mobile.js
index 1c2c76b..1a9e153 100644
--- a/www/js/mobile.js
+++ b/www/js/mobile.js
@@ -205,10 +205,14 @@ function check_name( name, msg ) {
}
function fileUploadSuccess(r) {
- console.log( r.response );
- console.log( typeof r.response );
if ( r.response ) {
- var data = JSON.parse( r.response );
+ var data;
+ try {
+ data = JSON.parse( decodeURIComponent(r.response) );
+ }
+ catch(err) {
+ data = {};
+ }
if ( data.success ) {
if ( data.report ) {
localStorage.report = data.report;
@@ -272,8 +276,9 @@ function postReport(e) {
var options = new FileUploadOptions();
options.fileKey="photo";
options.fileName=fileURI.substr(fileURI.lastIndexOf('/')+1);
- options.mimeType="image/jpeg";
+ options.mimeType="image/jpeg";
options.params = params;
+ options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(fileURI, CONFIG.FMS_URL + "report/new/mobile", fileUploadSuccess, fileUploadFail, options);