如何将保存的视频上传到远程服务器,使用cordovaCapture捕获? [英] How to upload saved video to a remote server, captured using cordovaCapture?

查看:1922
本文介绍了如何将保存的视频上传到远程服务器,使用cordovaCapture捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cordovaCapture的captureVideo方法如下:

I am using the captureVideo method of cordovaCapture as follows:

$cordovaCapture.captureVideo(options)
  .then(function(videoData) {
    var file_path = videoData[0].fullPath;
   // upload to server
});

我得到的文件路径为


file:/ storage / .... mp4

file:/storage/....mp4

如何将此文件上传到远程服务器,我将能够通过我的控制器直接访问这个文件或者我必须处理一个url吗?

How to upload this file to a remote server, will I be able to access this file directly through my controller or will I have to process a url out of it?

我使用Ionic框架。

I am using the Ionic framework.

任何帮助将非常感激。

Any help would be much appreciated.

推荐答案

这很简单。这将只工作在离子FW

It is pretty simple. This will work only in ionic FW

首先你必须安装文件传输插件。如果不使用此命令:

first you must be installed file transfer plugin. if not use this command:

cordova插件添加org.apache.cordova.file-transfer

假设 http://www.samplewebsite.com/upload 。是您的服务器超链接。

assume http://www.samplewebsite.com/upload. is your server hyperlink.

example.controller("ExampleController", function($scope, $cordovaFileTransfer) {

    $scope.upload = function() {
        var options = {
            fileKey: "avatar",
            fileName: "filename.mp4",
            chunkedMode: false,
            mimeType: "video/mp4"
        };
        $cordovaFileTransfer.upload("http://www.samplewebsite.com/upload", "file:/storage/....mp4", options).then(function(result) {
            console.log("SUCCESS: " + JSON.stringify(result.response));
        }, function(err) {
            console.log("ERROR: " + JSON.stringify(err));
        }, function (progress) {
            // constant progress updates
        });
    }

});

毕竟你需要像这样调用这个函数

after all you need to call this function like this

<button class="button" ng-click="upload()">video upload</button>

它的工作。我已经做了很多次。

Its working. I have done many times.

这篇关于如何将保存的视频上传到远程服务器,使用cordovaCapture捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆