Meteor-Community-Packages/Meteor-CollectionFS

How to save thumb into filesystem with FS.Collection S3

spk2piyu opened this issue · 0 comments

I am trying to achieve something like this, where thumb image of S3 upload will be saved into filesystem.

export const S3ThumbsStore = new FS.Store.FileSystem("s9thumb", { path: process.env.PWD +"/uploads",
 
  transformWrite : function(fileObj, readStream, writeStream) {
    // Resize to 32x32
    const gm = require('gm');
    console.log('It is comin here but some issue with ', readStream)
    gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream);
    
  }
});

if (Meteor.isServer) {
  var imageStore = new FS.Store.S3("s3-images", {
    /* REQUIRED */
    accessKeyId: Meteor.settings.private.AWSAccessKeyId, 
    secretAccessKey: Meteor.settings.private.AWSSecretAccessKey, 
    bucket: Meteor.settings.private.AWSBucket
  });

 S3Images = new FS.Collection("TalkeysImages", {
    stores: [imageStore,**S3ThumbsStore**],
    filter: {
      allow: {
        contentTypes: ['image/*']
      },
        onInvalid: function(message) {
        console.error(message);
      }
    }
  });
}