无法将大尺寸视频上传到 Firebase

Failed on uploading high sized videos to Firebase

我正在使用 angular 和 firebase 开发网络应用程序。此外,我希望我的用户能够将大视频上传到 firebase。

但问题是,当我尝试上传大于 10485760 字节的视频时,出现以下错误:

angular.js:13294 Error: Firebase.set failed: First argument contains a string greater than 10485760 utf8 bytes in property 'posts.-KDiuigtRhbVxoAocPBb.source' ('data:video/quicktime;base64,AAAAFGZ0eXBxdCAgAAAAAH...')

这里有什么工作可以实现吗?


我现在拥有的差不多:

.html

<span class="btn btn-default btn-file">
    <input type="file" accept="video/*" capture="camera" id="file-upload">
</span>
<div class="field button">
    <button ng-click="createPost()" ng-hide="createMode">Post</button>
</div>

控制器

$scope.createPost = function() {
    if ($scope.postVideoData) {
      $scope.post.createdAt = new Date().toString();
      $scope.post.source = $scope.postVideoData;
      $scope.post.sourceType = "VIDEO";
    }
    $publisherServices.create($scope.post, user);
    $location.path("/" + $routeParams.associate);
  };

$publisherServices

.service('$publisherServices', function($firebaseArray, FBURL, $sharedProperties, $location, $routeParams) {

  var ref = new Firebase(FBURL).child("posts");
  var posts = $firebaseArray(ref);
  return {
    all: posts,
    create: function(post, user) {
      post.ownedBy = $sharedProperties.getCurrentAssociate().$id;
      post.postedBy = user.uid;
      //Add to firebase db
      return posts.$add(post);
    }
  };
});

来自Firebase documentation on limitations and restrictions

Size of one child value

Limit: 10mb (UTF-8 encoded)

您收到一条错误消息,提示您超出了该限制。由于 非常 充分的理由,无法更改该限制。

在 Firebase 实时数据库中存储大型媒体文件不是一个好主意。它不是一个媒体存储层,而是一个实时同步合理大小数据的数据库。

要存储媒体文件,请使用专用服务(S3、GCS 等),然后使用 Firebase 来存储和传送 URL。