Turistforeningen / node-s3-uploader

Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
https://www.npmjs.com/package/s3-uploader
MIT License
241 stars 54 forks source link

File type .xcf (GIMP file) causing uncatchable error #115

Open georgezhang opened 7 years ago

georgezhang commented 7 years ago

When resize and upload a file .xcf it can crash the nodejs process as error below. The problem is due to imagemagick generated multple files for individual layers after resized .xcf . The file name with suffix -n.jpg unmatched with the version path in _upload function. fs.createReadStream(version.path) emitted error not catchable inside aws-sdk.

events.js:141 throw er; // Unhandled 'error' event ^

Error: ENOENT: no such file or directory, open 'uploads/92c4fce2-e7f0-4ff7-8e3c-9245e3f7ea26/arrow_4_xxl-thumb1.jpg' at Error (native)

[nodemon] app crashed - waiting for file changes before starting...

Temporary fix suggestion (validate the existence of version.path):

Image.prototype._upload = function _upload(dest, version, cb) { fs.stat(version.path, function (err_file) { if (err_file) return cb(err_file); ...... }); };

anthonyringoet commented 7 years ago

@georgezhang If you have a solution for this problem, feel free to publish a pull request.