couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Charette <ioma...@yahoo.com>
Subject Re: Connecting streams to cradle and couchdb attachments
Date Wed, 03 Apr 2013 02:49:41 GMT
I realize I'm talking to myself :)

I've updated it to use nano (way cleaner for attachments) and still have a endless write loop
to couch but file streams ok.  How do I stop it?

im(result.buffer, v.name)
.resize(s.width, s.height)
.autoOrient()
.stream(function (err, stdout, stderr) {
	var writeStream = fs.createWriteStream('./temp/' + fileName);
	stdout.pipe(endue.attachment.insert(dd.id, fileName, null, v.type, { rev: dd.rev }));
});

Thanks!
Jeff Charette | Principal 
We Are Charette
web / identity / packaging

m  415.298.2707
w  wearecharette.com
e   jeffrey@wearecharette.com

On Apr 2, 2013, at 8:53 PM, Jeff Charette <iomatix@yahoo.com> wrote:

> Reformatted post!
> 
> This is a nodejs question concerning couchdb attachments.  It seems too specific to post
on stack overflow.  Sorry to ask on here!  I have 2 very long days into this so any help is
deeply appreciated!
> 
> I am trying to connect a write stream from graphicsmagic to a readstream in cradle in
order to send a document I processed with graphics magic to couchdb. 
> 
> /* this makes the files, but loops infinitely */
> im(result.buffer, v.name)
> .resize(s.width, s.height)
> .autoOrient()
> .write("./temp/" + s.width + 'x' + s.height + v.name, function (err) { // <-- this
is the write stream
> 	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) // <-- this
is the read stream
> 		};
> 		db.saveAttachment(docId, attachmentData, function (err, reply) {
> 		  if (err) {
> 		    console.log(err)
> 		    return
> 		  }
> 		  console.log(reply)
> 		});
> 	}
> });
> 
> Theses are the docs I am pulling from:
> 
> https://github.com/aheckmann/gm
> https://github.com/cloudhead/cradle
> 
> Is anyone doing this?  Maybe doing it another way?  I don't care whether I use cradle
or not just that I send the processed attachment to couch.
> Jeff Charette | Principal 
> We Are Charette
> web / identity / packaging
> 
> m  415.298.2707
> w  wearecharette.com
> e   jeffrey@wearecharette.com
> 
> On Apr 2, 2013, at 8:22 PM, Jeff Charette <iomatix@yahoo.com> wrote:
> 
>> This is a nodejs question concerning couchdb attachments.  It seems too specific
to post on stack overflow.  I have 2 very long days into this so any help is deeply appreciated!
>> 
>> I am trying to connect a write stream from graphicsmagic to a readstream in cradle
in order to send a document I processed with graphics magic to couchdb. 
>> 
>> /* this makes the files, but loops infinitely */
>> 									im(result.buffer, v.name)
>> 									.resize(s.width, s.height)
>> 									.autoOrient()
>> 									.write("./temp/" + s.width + 'x' + s.height + v.name, function (err) { //
<-- this is the write stream
>> 									 	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)
// <-- this is the read stream
>> 											};
>> 											db.saveAttachment(docId, attachmentData, function (err, reply) {
>> 											  if (err) {
>> 											    console.log(err)
>> 											    return
>> 											  }
>> 											  console.log(reply)
>> 											});
>> 										}
>> 									});
>> 
>> Theses are the docs I am pulling from:
>> 
>> https://github.com/aheckmann/gm
>> https://github.com/cloudhead/cradle
>> 
>> Is anyone doing this?  Maybe doing it another way?  I don't care whether I use cradle
or not just that I send the processed attachment to couch.
>> 
>> Jeff Charette | Principal 
>> We Are Charette
>> web / identity / packaging
>> 
>> m  415.298.2707
>> w  wearecharette.com
>> e   jeffrey@wearecharette.com
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message