Diego Murru
Posts: 0
Joined: Fri Apr 04, 2014 2:58 pm

transfer a video from app to external server

Hi

I need help to transfer a video from my app to an external server.

I can record the video using this code:

code
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles&#46;length; i < len; i += 1) {
path = mediaFiles&#46;fullPath;
Appery("labelVideoUrl")&#46;text(path);
&#47;&#47; do something interesting with the file
}
};
&#47;&#47; capture error callback
var captureError = function(error) {
navigator&#46;notification&#46;alert('Error code: ' + error&#46;code, null, 'Capture Error');
};
&#47;&#47; start video capture
navigator&#46;device&#46;capture&#46;captureVideo(captureSuccess, captureError, {duration:100});
/code

After registration I get this string

code
/private/var/mobile/Applications/9B7726E0-ADF5-4D65-A2AF-EDDCAA282306/tmp/capture-T0x16e0dc20&#46;tmp&#46;NBvYID/capturedvideo&#46;MOV
/code

after i invoke a javascript function like this:

code
&#47;&#47; Upload files to server
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile&#46;fullPath,
name = mediaFile&#46;name;

Code: Select all

     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

where am I doing wrong?

Thanks
Diego

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

transfer a video from app to external server

Hello!

Could you clarify what is the error you get?
What is the libraries version and what device you use to test?
Did you install app on device?

Diego Murru
Posts: 0
Joined: Fri Apr 04, 2014 2:58 pm

transfer a video from app to external server

Hi Maryna

thanks for your reply

I tested the app natively on an iphone 5. I can record the video and I have a patch of its temporary location, but when I try to make the transfer on the external server I do not have any results.

I forwarded the temporary location on a label to see their position.

I uploaded this javascript code on a submit button, but when I click I do not have any results.

code
var video = Appery('labelVideoUrl')&#46;text();

&#47;&#47; Upload files to server
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = video&#46;fullPath,
name = video&#46;name;

Code: Select all

     ft&#46;upload(path, 
         "http:&#47;&#47;www&#46;xxx&#46;com/beta/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

where am I doing wrong?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

transfer a video from app to external server

Hello!

1) In your code video is labelVideoUrl label value (string). Then you are trying to retrieve video.fullPath and video.name. For string these methods are not defined. Please check what are path and name equal to, show values in alert
2) Do you call uploadFile function?

Return to “Issues”