I am trying to make resizing of a photo and uploading to a server synchronous. I believe the key will be making the stream function synchronous.
function upload(photo, newname, size, cb) {
gm(request(photo))
.resize(size[0], size[1])
.stream(function(err, stdout, stderr) {
var buf = new Buffer('');
stdout.on('data', function(data) {
buf = Buffer.concat([buf, data]);
});
stdout.on('end', function(data) {
var data = {
Bucket: config.s3_bucket_photos,
Key: newname,
Body: buf,
ACL: 'public-read',
ContentType: "image/jpeg"
};
uploadToServerSynchronous(data, cb);
});
});
}
from Synchronous resize and upload using graphicsmagick
No comments:
Post a Comment