Uploading videos from phones' library step by step instructions
Can anyone give me the step-by-step instructions or full code to upload video from the phone's library
(No need to record and upload)
Thank you!
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Can anyone give me the step-by-step instructions or full code to upload video from the phone's library
(No need to record and upload)
Thank you!
Hello Mark,
Please check these threads:
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...
I have put this JS code when the button click,
However, nothing happens, (I have used Android Phone to test)
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': '54d8de85e4b0e533414a7256',
'X-Appery-Session-Token': localStorage.getItem("userSessionToken")
};
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURI.substr(fileURI.lastIndexOf('/') + 1);
options.mimeType = 'video/mp4';
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);
Here is my code when button click,
The default format of the video recording is 3gp? So I change the MimeType to 3gp and add the headers. However, it still not working
It had recorded the video and stored in the phone but didn't upload
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/files",
// !! Assumes variable fileURI contains a valid URI to a text file on the device
var headers={
'X-Appery-Database-Id': '54d8de85e4b0e533414a7256',
'X-Appery-Session-Token': localStorage.getItem("userSessionToken")
};
function uploadVideo(mediaFiles){
var options = new FileUploadOptions();
options.fileKey="mediaFiles";
options.fileName=mediaFiles.substr(mediaFiles.lastIndexOf('/')+1);
options.mimeType="video/3gp";
options.headers= headers ;
var ft = new FileTransfer();
ft.upload(mediaFiles.fullPath, encodeURI("https://api.appery.io/rest/1/db/files"), 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);
}
Hello Mark!
I am sorry for such a big delay! We were trying to find a solutions, but no avail. This seems to be a time consuming task (up to 2 hours) which we can't afford. You may consider purchasing Advisory Pack to get more in-depth help on this question. Here is more information about Advisory Pack http://appery.io/services/#Advisory_Pack.