Page 3 of 5

Audio Recorder

Posted: Fri Jul 25, 2014 5:26 am
by Lim Samantha

hi tried doing that way, still doesn't work

Image


Audio Recorder

Posted: Fri Jul 25, 2014 6:23 pm
by Evgene Karachevtsev

Hello Lim,

You have not the full code. They do not send anything. Please look carefully at post which we recommended.


Audio Recorder

Posted: Tue Jul 29, 2014 4:35 am
by Lim Samantha

Hi,
so i am suppose to add in this codes?

function win(r) {
alert("Code = " + r.responseCode);
alert("Response = " + r.response);
alert("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
alert("upload error source " + error.source);
alert("upload error target " + error.target);
}
var fileURI = data.imageURI;
var headers = {
'X-Appery-Database-Id': 'XXXXXXXXXXXXXXXX',
'X-Appery-Session-Token': localStorage.getItem("userSessionToken")
};
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
options.mimeType = 'image/jpeg';
options.headers = headers;
var uri = encodeURI("https://api.appery.io/rest/1/db/files/" + options.fileName);
var ft = new FileTransfer();
ft.upload(fileURI, uri, win, fail, options);


Audio Recorder

Posted: Wed Jul 30, 2014 1:03 am
by Alena Prykhodko

Hi,

Yes. Let us know the result.


Audio Recorder

Posted: Wed Jul 30, 2014 3:11 am
by Lim Samantha

Hi, after adding in the codes, nothing happen

http://appery.io/app/mobile-frame?src...
Image

it is not saved in database. and how do i know if i have recorded something? since it is a button click.

please do assist, maybe u can go into my application and try. thanks

http://appery.io/app/project/8ede79da...


Audio Recorder

Posted: Wed Jul 30, 2014 1:36 pm
by Evgene Karachevtsev

Hello Lim,

Could you please provide us with the full code that you have on the screenshot (on the screenshot it is not fully fit)?


Audio Recorder

Posted: Thu Jul 31, 2014 3:20 am
by Lim Samantha

here is the code:

function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
function win(r) {
alert("Code = " + r.responseCode);
alert("Response = " + r.response);
alert("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
alert("upload error source " + error.source);
alert("upload error target " + error.target);
}
var fileURI = data.imageURI;
var headers = {
'X-Appery-Database-Id': 'XXXXXXXXXXXXXXXX',
'X-Appery-Session-Token': localStorage.getItem("userSessionToken")
};
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
options.mimeType = 'image/jpeg';
options.headers = headers;
var uri = encodeURI("https://api.appery.io/rest/1/db/files/" + options.fileName);
var ft = new FileTransfer();
ft.upload(fileURI, uri, win, fail, options);
}
}

Code: Select all

 // Called if something bad happens. 
 // 
 function captureError(error) { 
     var msg = 'An error occurred during capture: ' + error.code; 
     navigator.notification.alert(msg, null, 'Uh oh!'); 
 } 

 // A button will call this function 
 // 
 function captureImage() { 
     // Launch device camera application, 
     // allowing user to capture up to 2 images 
     navigator.device.capture.captureImage(captureSuccess, captureError, {limit: 2}); 
 } 

 // Upload files to server 
 function uploadFile(mediaFile) { 
     var ft = new FileTransfer(), 
         path = mediaFile.fullPath, 
         name = mediaFile.name; 

     ft.upload(path, 
         "[url=http://my.domain.com/upload.php]http://my.domain.com/upload.php[/url]", 
         function(result) { 
             console.log('Upload success: ' + result.responseCode); 
             console.log(result.bytesSent + ' bytes sent'); 
         }, 
         function(error) { 
             console.log('Error uploading file ' + path + ': ' + error.code); 
         }, 
         { fileName: name }); 
 }

Audio Recorder

Posted: Fri Aug 01, 2014 12:33 am
by obullei

Hello!

Could you provide the whole code ( unfortunately we can not see it on your screenshot)? We will try to solve your problem.


Audio Recorder

Posted: Fri Aug 01, 2014 4:15 am
by nadiah jabbar

hi, i have provided the codes above.
this codes are from the screenshot

function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
function win(r) {
alert("Code = " + r.responseCode);
alert("Response = " + r.response);
alert("Sent = " + r.bytesSent);
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
alert("upload error source " + error.source);
alert("upload error target " + error.target);
}
var fileURI = data.imageURI;
var headers = {
'X-Appery-Database-Id': 'XXXXXXXXXXXXXXXX',
'X-Appery-Session-Token': localStorage.getItem("userSessionToken")
};
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
options.mimeType = 'image/jpeg';
options.headers = headers;
var uri = encodeURI("https://api.appery.io/rest/1/db/files/" + options.fileName);
var ft = new FileTransfer();
ft.upload(fileURI, uri, win, fail, options);
}
}

// Called if something bad happens.
//
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}

// A button will call this function
//
function captureImage() {
// Launch device camera application,
// allowing user to capture up to 2 images
navigator.device.capture.captureImage(captureSuccess, captureError, {limit: 2});
}

// Upload files to server
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;

ft.upload(path,
"http://my.domain.com/upload.php",
function(result) {
console.log('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function(error) {
console.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}


Audio Recorder

Posted: Fri Aug 01, 2014 12:57 pm
by Evgene Karachevtsev

Hello,

1) Could you please clarify, do you need this function?

code&#47;&#47; Upload files to server
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile&#46;fullPath,
name = mediaFile&#46;name;
ft&#46;upload(path, "http:&#47;&#47;my&#46;domain&#46;com/upload&#46;php",
function(result) {
console&#46;log('Upload success: ' + result&#46;responseCode);
console&#46;log(result&#46;bytesSent + ' bytes sent');
},
function(error) {
console&#46;log('Error uploading file ' + path + ': ' + error&#46;code);
}, {
fileName: name
});
}/code

Maybe it's better to delete it?

2) You do not cause captureimage. At the bottom of the code you should add the line

codecaptureimage command();/code

3) Could you please check whether you have filled in all of the settings for database access:
a) X-Appery-Database-Id (in your code XXXXXXXXXXXXXXXX - you should put the correct value)
b) do you have the localStorage variable userSessionToken