Meteor Galaxy and S3 image manipulation 'imagemagick-stream' resize not working. Thumbnail not being created (0B).
pedrofg opened this issue · 0 comments
Hi Guys, trying to upload images to Amazon S3. The server used is the Meteor Galaxy. The issue is that for large images the thumbnail is not being generated properly, it creates a file in the S3 with 0 Bytes.
I Enabled the log FS.debug = true;
That is the TransformWrite function:
transformWrite: function(fileObj, readStream, writeStream) {
let im = require('imagemagick-stream');
const resize = im().resize('150x150').quality(75);
readStream.pipe(resize).pipe(writeStream);
}
If I do not do use the const resize
and do just readStream.pipe(writeStream);
it works but, does not create the resized thumbnail of course.
Important fact: It works fine on my local machine in the development environment (images >5 MB) and it also works on the server with smaller images < 5 MB.
That is my server log:
2018-03-02 12:06:38-05:00token: eyJhdXRoVG9rZW4iOiJUZ0o1UTdYUE05OVZUellfazJjaXpjaDkzb1FfR1QtbXJ4a1NsRl9pREZFIn0=
2018-03-02 12:06:38-05:00HTTP PUT (update) handler received chunk: 0
2018-03-02 12:06:38-05:00GET FILERECORD: XsRW4FZix7LTjMHfz
2018-03-02 12:06:39-05:00TempStore is mounted on storage.gridfs
2018-03-02 12:06:39-05:00createWriteStream _tempstore, internal: true
2018-03-02 12:06:39-05:00createWriteStreamForFileKey _tempstore
2018-03-02 12:06:42-05:00SA GridFS - DONE!
2018-03-02 12:06:42-05:00-----------STORED STREAM _tempstore
2018-03-02 12:06:42-05:00-----------CLOSE STREAM _tempstore
2018-03-02 12:06:42-05:00-----------FINISH STREAM _tempstore
2018-03-02 12:06:42-05:00TempStore progress: Received 1 of 3 chunks for bottle.jpg
2018-03-02 12:06:42-05:00UPDATE: {"$set":{"chunkCount":1}}
2018-03-02 12:06:42-05:00token: eyJhdXRoVG9rZW4iOiJUZ0o1UTdYUE05OVZUellfazJjaXpjaDkzb1FfR1QtbXJ4a1NsRl9pREZFIn0=
2018-03-02 12:06:42-05:00HTTP PUT (update) handler received chunk: 1
2018-03-02 12:06:42-05:00GET FILERECORD: XsRW4FZix7LTjMHfz
2018-03-02 12:06:42-05:00createWriteStream _tempstore, internal: true
2018-03-02 12:06:42-05:00createWriteStreamForFileKey _tempstore
2018-03-02 12:06:46-05:00SA GridFS - DONE!
2018-03-02 12:06:46-05:00-----------STORED STREAM _tempstore
2018-03-02 12:06:46-05:00-----------CLOSE STREAM _tempstore
2018-03-02 12:06:46-05:00-----------FINISH STREAM _tempstore
2018-03-02 12:06:46-05:00TempStore progress: Received 2 of 3 chunks for bottle.jpg
2018-03-02 12:06:46-05:00UPDATE: {"$set":{"chunkCount":2}}
2018-03-02 12:06:46-05:00token: eyJhdXRoVG9rZW4iOiJUZ0o1UTdYUE05OVZUellfazJjaXpjaDkzb1FfR1QtbXJ4a1NsRl9pREZFIn0=
2018-03-02 12:06:46-05:00HTTP PUT (update) handler received chunk: 2
2018-03-02 12:06:46-05:00GET FILERECORD: XsRW4FZix7LTjMHfz
2018-03-02 12:06:46-05:00createWriteStream _tempstore, internal: true
2018-03-02 12:06:46-05:00createWriteStreamForFileKey _tempstore
2018-03-02 12:06:48-05:00SA GridFS - DONE!
2018-03-02 12:06:48-05:00-----------STORED STREAM _tempstore
2018-03-02 12:06:48-05:00-----------CLOSE STREAM _tempstore
2018-03-02 12:06:48-05:00-----------FINISH STREAM _tempstore
2018-03-02 12:06:48-05:00TempStore progress: Received 3 of 3 chunks for bottle.jpg
2018-03-02 12:06:48-05:00UPDATE: {"$set":{"uploadedAt":"2018-03-02T17:06:48.113Z"},"$unset":{"chunkCount":1,"chunkSum":1,"chunkSize":1}}
2018-03-02 12:06:48-05:00bottle.jpg was successfully uploaded. You are seeing this informational message because you enabled debugging and you have not defined any listeners for the "uploaded" event on the images collection.
2018-03-02 12:06:48-05:00FileWorker ADDED - calling saveCopy images for XsRW4FZix7LTjMHfz
2018-03-02 12:06:48-05:00saving to store images
2018-03-02 12:06:48-05:00createWriteStream images, internal: false
2018-03-02 12:06:48-05:00createWriteStreamForFileKey images
2018-03-02 12:06:48-05:00FS.TempStore creating read stream for XsRW4FZix7LTjMHfz
2018-03-02 12:06:48-05:00FileWorker ADDED - calling saveCopy thumbs for XsRW4FZix7LTjMHfz
2018-03-02 12:06:48-05:00saving to store thumbs
2018-03-02 12:06:48-05:00createWriteStream thumbs, internal: false
2018-03-02 12:06:48-05:00createWriteStreamForFileKey thumbs
2018-03-02 12:06:48-05:00FS.TempStore creating read stream for XsRW4FZix7LTjMHfz
2018-03-02 12:06:48-05:00createReadStream _tempstore
2018-03-02 12:06:48-05:00createReadStreamForFileKey _tempstore
2018-03-02 12:06:48-05:00GRIDFS { _id: 5a99849fdf02b4000642d09e, root: 'cfs_gridfs._tempstore' }
2018-03-02 12:06:48-05:00createReadStream _tempstore
2018-03-02 12:06:48-05:00createReadStreamForFileKey _tempstore
2018-03-02 12:06:48-05:00GRIDFS { _id: 5a99849fdf02b4000642d09e, root: 'cfs_gridfs._tempstore' }
2018-03-02 12:06:49-05:00createReadStream _tempstore
2018-03-02 12:06:49-05:00createReadStreamForFileKey _tempstore
2018-03-02 12:06:49-05:00GRIDFS { _id: 5a9984a2df02b4000642d0a1, root: 'cfs_gridfs._tempstore' }
2018-03-02 12:06:49-05:00createReadStream _tempstore
2018-03-02 12:06:49-05:00createReadStreamForFileKey _tempstore
2018-03-02 12:06:49-05:00GRIDFS { _id: 5a9984a2df02b4000642d0a1, root: 'cfs_gridfs._tempstore' }
2018-03-02 12:06:49-05:00createReadStream _tempstore
2018-03-02 12:06:49-05:00createReadStreamForFileKey _tempstore
2018-03-02 12:06:49-05:00GRIDFS { _id: 5a9984a6df02b4000642d0a4, root: 'cfs_gridfs._tempstore' }
2018-03-02 12:06:50-05:00-----------FINISH STREAM thumbs
2018-03-02 12:06:50-05:00-----------END STREAM thumbs
2018-03-02 12:06:50-05:00createReadStream _tempstore
2018-03-02 12:06:50-05:00createReadStreamForFileKey _tempstore
2018-03-02 12:06:50-05:00GRIDFS { _id: 5a9984a6df02b4000642d0a4, root: 'cfs_gridfs._tempstore' }
2018-03-02 12:06:51-05:00-----------FINISH STREAM images
2018-03-02 12:06:51-05:00-----------FINISH STREAM images
2018-03-02 12:06:55-05:00SA S3 - DONE!!
2018-03-02 12:06:55-05:00-----------STORED STREAM images
2018-03-02 12:06:55-05:00-----------STORED STREAM images
2018-03-02 12:06:55-05:00SA images stored images/XsRW4FZix7LTjMHfz-bottle.jpg
2018-03-02 12:06:55-05:00FS.File._saveChanges: images
2018-03-02 12:06:55-05:00UPDATE: {"$set":{"copies.images":{"name":"bottle.jpg","type":"image/jpeg","size":4989595,"key":"images/XsRW4FZix7LTjMHfz-bottle.jpg","updatedAt":"2018-03-02T17:06:55.088Z","createdAt":"2018-03-02T17:06:55.088Z"}}}
2018-03-02 12:06:55-05:00bottle.jpg was successfully saved to the images store. You are seeing this informational message because you enabled debugging and you have not defined any listeners for the "stored" event on the images collection.
2018-03-02 12:06:55-05:00FS.File._saveChanges: _original
2018-03-02 12:06:55-05:00UPDATE: {"$set":{"original":{"name":"bottle.jpg","updatedAt":"2018-03-01T16:11:41.364Z","size":4989595,"type":"image/jpeg"}}}
2018-03-02 12:06:59-05:00-----------FINISH STREAM thumbs
2018-03-02 12:07:00-05:00SA S3 - DONE!!
2018-03-02 12:07:00-05:00-----------STORED STREAM thumbs
2018-03-02 12:07:00-05:00-----------STORED STREAM thumbs
2018-03-02 12:07:00-05:00SA thumbs stored images/XsRW4FZix7LTjMHfz-bottle.jpg
2018-03-02 12:07:00-05:00FS.File._saveChanges: thumbs
2018-03-02 12:07:00-05:00UPDATE: {"$set":{"copies.thumbs":{"name":"bottle.jpg","type":"image/jpeg","size":0,"key":"images/XsRW4FZix7LTjMHfz-bottle.jpg","updatedAt":"2018-03-02T17:07:00.813Z","createdAt":"2018-03-02T17:07:00.813Z"}}}
2018-03-02 12:07:00-05:00ThumbStoreFS on Stored, File id:
2018-03-02 12:07:00-05:00XsRW4FZix7LTjMHfz
2018-03-02 12:07:00-05:00bottle.jpg was successfully saved to the thumbs store. You are seeing this informational message because you enabled debugging and you have not defined any listeners for the "stored" event on the images collection.
2018-03-02 12:07:00-05:00FS.File._saveChanges: _original
2018-03-02 12:07:00-05:00UPDATE: {"$set":{"original":{"name":"bottle.jpg","updatedAt":"2018-03-01T16:11:41.364Z","size":4989595,"type":"image/jpeg"}}}