Closed swhamilton closed 10 years ago
As an update, I found that the error is not linked to the file size but to the image resolution. The original image that was giving me trouble was 5000x3500px.
I tested a 2000x1333 image and saved as png (~4MB) and it worked as expected. There is some issue with imageMagick resizing large images, but for now I can live with the constraints.
I found a strange issue when loading images with larger file size (1MB+) on my production environment. After the initial file is uploaded, only one of the imageVersions is process/saved. Also, the imageVersion that is saved is not consistent (sometimes large, sometimes small, etc.)
When testing locally everything works as expected, and all imageVersions are saved.
I have been using the example code provided with the module:
var resizeConf = require('./config').resizeVersion; app.use('/upload/location', upload.fileHandler({ tmpDir: dirs.temp, uploadDir: __dirname + dirs.location, uploadUrl: dirs.location_url, imageVersions: resizeConf.location }));
CONSOLE OUTPUT: files upload complete { name: '1MB-Picture.jpg', originalName: '1MB-Picture.jpg', size: 1154230, type: 'image/jpeg', deleteType: 'DELETE', url: 'http://localhost:8000/uploads/location/1MB-Picture.jpg', deleteUrl: 'http://localhost:8000/upload/location/1MB-Picture.jpg', thumbnailUrl: 'http://localhost:8000/uploads/location/thumbnail/1MB-Picture.jpg', smallUrl: 'http://localhost:8000/uploads/location/small/1MB-Picture.jpg', mediumUrl: 'http://localhost:8000/uploads/location/medium/1MB-Picture.jpg', largeUrl: 'http://localhost:8000/uploads/location/large/1MB-Picture.jpg' }
But when the exact same setup on my Debian virtual machine I get this:
CONSOLE OUTPUT: files upload complete { name: '1MB-Picture.jpg', originalName: '1MB-Picture.jpg', size: 1154230, type: 'image/jpeg', deleteType: 'DELETE', url: 'http://dev.mywebsite.com/uploads/location/1MB-Picture.jpg', deleteUrl: 'http://dev.mywebsite.com/upload/location/1MB-Picture.jpg', mediumUrl: 'http://dev.mywebsite.com/uploads/location/medium/1MB-Picture.jpg' }
Also, when I go to delete the upload and let jquery-file-upload-middleware clean up the imageVersions, I get this error:
CONSOLE OUTPUT: files remove complete 1MB-Picture.jpg fs: missing callback Error: ENOENT, unlink '/mywebsite/public/uploads/location/thumbnail/1MB-Picture.jpg' fs: missing callback Error: ENOENT, unlink '/mywebsite/public/uploads/location/small/1MB-Picture.jpg' fs: missing callback Error: ENOENT, unlink '/mywebsite/public/uploads/location/large/1MB-Picture.jpg'
When the file size is small (1KB for example), everything works as expected on the production machine.
Any idea what could be causing this? I suspect there is some race-condition with the async or fs module.