我正在开发一个应用程序,让人们上传短视频(8秒)来展示产品,问题是我无法弄清楚如何将捕获的cordova文件上传到GCS。
我使用了cordova文件传输插件,并使用我的应用程序识别的软件包创建了iOS API密钥,但我仍然无法上传视频。
我的代码
'use strict';
app.controller('VideoCtrl', function($scope, $cordovaCapture, $state, FURL, Videos) {
$scope.videos = Videos;
$scope.record = function(){
var options = { limit: 1, duration: 8 };
$cordovaCapture.captureVideo(options).then(
function(videoData) {
var i, path, len;
var pathtogo;
var pathtogostring;
for (i = 0, len = videoData.length; i < len; i += 1) {
path = videoData[i].fullPath;
pathtogo = path.toString();
$scope.videos.$add(pathtogo);
};
},
$state.go('tab.photo-detail'),
function(err) {
}
);
$cordovaFileTransfer.upload("https://www.googleapis.com/upload/storage/v1/b/'mybucket'/o?uploadType=media", videoData[i].fullPath, {mimeType: "video/mov", fileName:"capturedvideo.MOV"}, true)
.then(function(result) {
console.log("SUCCESS: " + JSON.stringify(result.response));
}, function(err) {
console.log("ERROR: " + JSON.stringify(err));
}, function (progress) {
// constant progress updates
});
};
});
感谢。