meteor cfs:filesystem 从 ios 上传到服务器导致零字节文件

meteor cfs:filesystem upload from ios to server result in zero bytes file

我 运行 在 iOS 使用 cordova capture 和 cfs 文件系统。 捕获视频或图像后,我正在使用上传。 没有错误,但是文件最终大小为 zero/0。 (顺便说一句,我正在使用我的 macbook pro)

这是我的 collection 和商店声明:

Videos = new FS.Collection("eventVideos", {
  stores: [new FS.Store.FileSystem("eventVideos", {
      path: "~/Documents/dev/chain/public/videoUploads"})]
});

这是驻留在模板事件中的 cordova 捕获代码:

navigator.device.capture.captureImage(videoCaptureSuccess, videoCaptureError, {limit: 1});

我会为您省去 videoCaptureError 函数,因为它现在实际上没有做任何事情,但 videoCaptureSuccess 看起来像这样:

videoCaptureSuccess = function(mediaFiles) {
   var i, path, len;
   for(i = 0, len = mediaFiles.length; i < len; i++) {
     path = mediaFiles[i].fullPath;
     Videos.insert(mediaFiles[i], function(err, fileObj) {
       alert(fileObj.size());
       if(err) {
         console.log(err);
       }
     });
   }
 };

请注意 videoCaptureSuccess 中的警报 returns 一个正数表示其中有数据,图片也保存在设备上。

怎么了?

---更新---

当我从应用程序中单击相机时,此消息显示在 xcode 控制台中: 对尚未呈现的视图进行快照会生成空快照。确保您的视图在屏幕更新之前或快照之前至少渲染过一次。

最终使用 Meteor 论坛上的惊人支持解决了这个问题。 完整的解决方案是 here