Can't upload image to EC2 Instance with CollectionFS/GridFS ERR_CONNECTION_REFUSED

98 Views Asked by At

I'm working on a simple Meteor app which manages profile pictures, while working in local my project is working fine.

But after deploying it on an AWS EC2 instance (With Meteor-Up), every works fine, except the image upload.

I'm using CollectionFS (cfs:standard-packages, cfs:gridfs). Here's the code :

// 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");
      });
    }
  });
}

The security rules for my EC2 instance :

enter image description here

And here's the error showing when i execute the event which execute the Images.insert function.

enter image description here

The error ERR_CONNECTION_REFUSED is showing. I'm able to get the image id, but the image isUploaded function return false :

enter image description here

Why am i having this error and how can i solve this problem ? Is it due to my EC2 configuration or the code inside my Meteor Project ? Thanks !

1

There are 1 best solutions below

4
On

I’d suggest to switch to ostrio:files which is fully documented and up to date. GridFS is really old and buggy. You can then save your files securely to a S3 instance and keep your MongoDB size low.