无法使用CollectionFS / GridFS将图像上载到EC2实例ERR_CONNECTION_REFUSED

时间:2017-09-09 12:55:45

标签: meteor amazon-ec2 gridfs collectionfs

我正在制作一个管理个人资料图片的简单 Meteor app 在本地工作时我的项目工作正常

但是在将其部署到AWS EC2实例(使用Meteor-Up)之后,除了图像上传外,每个工作都正常。

我正在使用CollectionFS(cfs:standard-packages, cfs:gridfs)。 这是代码:

// Collection definition
Images = new FS.Collection("images", {
  stores: [new FS.Store.GridFS("original")]
});

Images.allow({
  'insert': function () {
    return true;
  },
  'update': function () {
    return true;
  },
  'download':function(){
    return true;
  }
});

// Event to upload the image
"click .js-validate"(event, instance){
  Images.insert(instance.file.get(), function (err, fileObj) {
    if(err){
      console.log("Error");
      console.log(err);
    }else{
      console.log("No error");
      console.log(err);
      Meteor.call('updatePP', fileObj._id, function(){
        Modal.hide("Modal_update_pp");
      });
    }
  });
}

我的EC2实例的安全规则:

enter image description here

这是我执行执行Images.insert功能的事件时出现的错误。

enter image description here

显示错误ERR_CONNECTION_REFUSED。 我可以获取图片ID,但图片isUploaded函数返回false

enter image description here

为什么我有这个错误,我该如何解决这个问题? 是因为我的EC2配置还是Meteor Project中的代码?谢谢!

1 个答案:

答案 0 :(得分:0)

我建议切换到ostrio:完全记录并且最新的文件。 GridFS非常老旧。然后,您可以将文件安全地保存到S3实例,并保持MongoDB的大小。