user3137766
user3137766

Reputation:

Titanium appcelerator upload recorded video to server

On my Appcelerator titanium mobile project i have to record video and upload this to our server. Recording is not difficult for me, it's quite easy, and i could return the video url properly from :

Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'myVideo.mp4');

so i can get native path :

myVideoPath =  f.nativePath;

From there i don't know how to upload the file, for an image i just base64 the blob, but for a video file how can handle this?

Thanks for your precious help.

Upvotes: 0

Views: 427

Answers (1)

miga
miga

Reputation: 4055

With a normal XHR request:

var f = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, "video.mp4");

var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function(e) {
    // done
};
xhr.open('POST', 'http://server/upload.php');
xhr.onsendstream = function(e) {
    console.log( Math.floor(e.progress * 100) + "%");
};
xhr.send({
    file: f
});

Then it depends on your server architecture.

With php it would be something like

if(move_uploaded_file($_FILES['video_path']['tmp_name'], "test.mp4")) {
    return "success";
} else{
    return "falied!";
}

Upvotes: 3

Related Questions