I am building a attachment handler with graphic magic and trying to stream
the results to couchdb with cradle or any other way. Below are two
attempts I have streaming and buffering that seem right, but loop. Any
help deeply appreciated as I have 2 very long days into this.
//streaming
/* this one makes a file that has no data in it and loops infinitely */
im(result.buffer, v.name)
.resize(s.width, s.height)
.autoOrient()
.stream(function (err, stdout, stderr) {
var writeStream = fs.createWriteStream("./temp/" + s.width + 'x' + s.height
+ v.name);
stdout.pipe(writeStream);
db.saveAttachment(docId, attachmentData, function (err, reply) {
if (err) {
console.log(err)
return
}
console.log(reply)
}, writeStream); // <-- this is the write stream from above
});
}
//buffering
/* this one creates the correct file, but loops infinitely as well */
im(result.buffer, v.name)
.resize(s.width, s.height)
.autoOrient()
.write("./temp/" + s.width + 'x' + s.height + v.name, function (err) {
if (!err) {
var attachmentData = {
name: s.width + 'x' + s.height + v.name,
'Content-Type': v.type,
body: fs.readFileSync("./temp/" + s.width + 'x' + s.height + v.name)
};
db.saveAttachment(docId, attachmentData, function (err, reply) {
if (err) {
console.log(err)
return
}
console.log(reply)
});
}
});
These are the docs I am looking at:
https://github.com/cloudhead/cradle
https://github.com/aheckmann/gm
Is there a better way to do this?
Thank you for your time helping a newb.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.