图片上传在Meteor中不起作用

时间:2015-10-28 13:43:46

标签: meteor

在我的流星应用程序中,我上传图像并将其存储在Dropbox中。当我在localhost中运行应用程序时,它工作正常。但是一旦我将应用程序部署到meteor.com后运行该应用程序,上传就无法正常工作。

这是我在server.js中的代码

var createThumb = function(fileObj, readStream, writeStream) {
// Transform the image into a 10x10px thumbnail
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
};

var dropboxStore = new FS.Store.Dropbox("files", {
key: "",
secret: "",
token: "", // Don’t share your access token with anyone.
transformWrite: createThumb, //optional
})

Images = new FS.Collection("files", {
   stores: [dropboxStore]
});

Images.allow({
'insert': function () {
    // add custom authentication code here
    return true;
 }
});

以下是meteor.com http://image_upload.meteor.com/的链接。

我尝试将Dropbox更改为s3,但它仍然无法正常工作。可能是因为它是在meteor.com上托管的吗?

期待解决方案。

1 个答案:

答案 0 :(得分:1)

很可能是因为您尝试使用GraphicsMagick调整 private object _CurrentItem; public object CurrentItem { get { return _CurrentItem; } set { _CurrentDocument = value; NotifyPropertyChanged(); //Make your logic for your combobox binding. } } 选项中的图像大小,但meteor.com托管服务器没有安装GraphicsMagick或ImageMagick。

https://github.com/CollectionFS/Meteor-CollectionFS/issues/299

您可以使用transformWrite命令查看托管的meteor.com应用程序中的日志,以确保问题出现。

修改

以下是jQuery cropper实用程序的一些示例代码:

模板HTML:

meteor logs

模板JS:

<input type="file" style="visibility:hidden;width:1px" accept="image/gif, image/jpeg, image/png" class="profilePhotoFile">
<input type="button" id="btnEditPhoto" value="Edit Photo" class="btn btn-primary" style="width:160px"/>

<div class="modal fade" id="cropper-modal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-body">
        <div id="cropper">
          <img src="" alt="Picture">
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" id="btnSavePhoto">Save</button>
        <button class="btn btn-default" id="btnCancel">Cancel</button>
      </div>
    </div>
  </div>
</div>