Hi, I am creating an app where users can record a video and upload it onto the Appery IO database collection that I called video. However, at the moment, with my existing code, I am only able to record video, but the file does not transfer to the Appery IO database.
Here is the code that I used:
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadVideo(mediaFiles);
}
};
// do something interesting with the file
// capture error callback
var captureError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
// start video capture
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1});
//"https://api.appery.io/rest/1/db/colle...",
// !! Assumes variable fileURI contains a valid URI to a text file on the device
function uploadVideo(mediaFiles){
var options = new FileUploadOptions();
options.fileKey="mediaFiles";
options.fileName=mediaFiles.substr(mediaFiles.lastIndexOf('/')+1);
options.mimeType="video/3gpp";
Code: Select all
var ft = new FileTransfer();
ft.upload(mediaFiles.fullPath, encodeURI("[url=https://api.appery.io/rest/1/db/collections/Video]https://api.appery.io/rest/1/db/colle...[/url]"), win, fail, options);
}
function win(r) {
alert("File successfully uploaded");
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
alert("upload error source " + error.source);
alert("upload error target " + error.target);
}