2

我正在尝试将文件上传到保管箱应用程序。使用带有cfs:dropbox适配器的CollectionFS/Meteor-CollectionFS包,我的问题是上传的文件是 0 字节。我不确定我在这里遗漏了什么或做错了什么。

在服务器上:

var registrationImageStorage = new FS.Store.Dropbox("registrationStorage", {
  key: "****",
  secret: "****",
  token: "****",
  transformWrite: function (fileObj, readStream, writeStream) {
    gm(readStream, fileObj.name()).stream().pipe(writeStream);
  }
});

RegistrationImages = new FS.Collection("registrations", {
  stores: [registrationImageStorage],
  filter: {
    allow: {
      contentTypes: ['image/*']
    }
  }
});

RegistrationImages.allow({
  insert: function () {
    return true;
  },
  update: function () {
    return true;
  }
});

在客户端:

var registrationImageStorage = new FS.Store.Dropbox("registrationStorage");

RegistrationImages = new FS.Collection("registrations", {
  stores: [registrationImageStorage],
  filter: {
    allow: {
      contentTypes: ['image/*']
    }
  }
});

在客户端开始上传:

var file = new FS.File($('#badgeImage').get(0).files[0]);

    RegistrationImages.insert(file, function (err, fileObj) {
      if (err) {
        console.log(err);
      } else {
        console.log(fileObj);
    });
4

1 回答 1

1

好的,我不需要这部分代码,删除它后,它起作用了:

transformWrite: function (fileObj, readStream, writeStream) {
    gm(readStream, fileObj.name()).stream().pipe(writeStream);
  }
于 2015-08-01T10:39:28.307 回答