Meteor-Community-Packages / Meteor-CollectionFS

Reactive file manager for Meteor
MIT License
1.05k stars 237 forks source link

FS.Transform is not resizing the Image - Meteor CollectionFS #878

Open MartiniHenry1988 opened 8 years ago

MartiniHenry1988 commented 8 years ago

I am trying to upload Image and keep its thumbnail as well.

I am using Meteor CollectionFS.

Here is my code:

Images = new FS.Collection("images", {
    stores: [
      new FS.Store.FileSystem("images", {path: '~/uploads'}),
      new FS.Store.FileSystem("thumbs", {path: '~/uploads/thumbs'}, {
        transformWrite: function(fileObj, readStream, writeStream) {
          // Transform the image into a 10x10px thumbnail
          gm(readStream, fileObj.name()).resize(10, 10).stream().pipe(writeStream);
        }
      }

      )
    ],
    filter: {
      allow: {
        contentTypes: ['image/*'] //allow only images in this FS.Collection
      }
    }
}); 

The above code is perfectly uploading the original image to /uploads directory, but it is not resizing the image. Means it uploads the original image to uploads/thumbs as well. I want a resized image to /uploads/thumbs directory and original Image to /uploads directory. What am I missing here? Why is an original image uploading to /uploads/thumbs directory?

graphicmagick is also installed on my Ubuntu 14.04

luisreyes commented 8 years ago

Having a very similar issue where the stores seem to be completely ignored and only the original is being uploaded.

var small = new FS.Store.GridFS('small',{
    transformWrite: function(fileObj, readStream, writeStream) {
        gm(readStream, fileObj.name).resize('320', '320').stream().pipe(writeStream);
    }
});

var medium = new FS.Store.GridFS('medium',{
    transformWrite: function(fileObj, readStream, writeStream) {
        gm(readStream, fileObj.name).resize('768', '768').stream().pipe(writeStream);
    }
});

var full = new FS.Store.GridFS('full',{
    transformWrite: function(fileObj, readStream, writeStream) {
        gm(readStream, fileObj.name).resize('1280', '1280').stream().pipe(writeStream);
    }
});

Images = new FS.Collection("images", {
    stores: [small, medium, full],
    filter: {
        allow: {
            contentTypes: ['image/*']
        }
    }
});

Locally everything work perfect... only when I deploy the issue happens.

Deploying to Digital Ocean - Ubuntu 14.04.3 x64 and graphicksmagick is installed there also.

ghost commented 8 years ago

Same solution as @luisreyes. It's work on VPS OVH - ubuntu 14.04.3 x46