Lim Samantha
Posts: 0
Joined: Wed Jun 11, 2014 6:50 am

Audio Recorder

hi tried doing that way, still doesn't work

Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Audio Recorder

Hello Lim,

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

Lim Samantha
Posts: 0
Joined: Wed Jun 11, 2014 6:50 am

Audio Recorder

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);

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Audio Recorder

Hi,

Yes. Let us know the result.

Lim Samantha
Posts: 0
Joined: Wed Jun 11, 2014 6:50 am

Audio Recorder

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...

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Audio Recorder

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)?

Lim Samantha
Posts: 0
Joined: Wed Jun 11, 2014 6:50 am

Audio Recorder

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 }); 
 }
obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

Audio Recorder

Hello!

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

nadiah jabbar
Posts: 0
Joined: Fri Jun 20, 2014 3:42 am

Audio Recorder

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 });
}

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Audio Recorder

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

Return to “Issues”