couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@gmail.com>
Subject Re: _attachments and thumbprints
Date Thu, 15 Jan 2009 21:45:07 GMT
On Thu, Jan 15, 2009 at 5:25 AM, Jeff Hinrichs - DM&T
<jeffh@dundeemt.com> wrote:
> Is it possible for a user to add calculated attributes to the
> _attachments dictionary?  Say I wanted to include the md5 hash of the
> attached file.  I realize that this is an expensive operation if you
> don't need it so I'm not asking if CouchDB could calc the MD5, but can
> I ?

My couchapp script does this on file upload. I just keep it in a
"signatures" field on the document, next to the attachments field.

See http://groups.google.com/group/couchapp for links to the
installation instructions.


>
>   "_attachments": {
>       "PRINV00541302.PDF": {
>           "stub": true,
>           "content_type": "application/pdf",
>           "length": 163502
>       },
>       "INV00541302.PDF": {
>           "stub": true,
>           "content_type": "application/pdf",
>           "length": 156047
>       }
>   }
>
> Can I modify via user code to:
>
>   "_attachments": {
>       "PRINV00541302.PDF": {
>           "stub": true,
>           "content_type": "application/pdf",
>           "length": 163502,
>           "md5": "1ba37b2a936dd5fe1415937c40b2cb02"
>       },
>       "INV00541302.PDF": {
>           "stub": true,
>           "content_type": "application/pdf",
>           "length": 156047,
>           "md5":"72ef73ff5040fcb9c8a90757b21c27eb"
>       }
>   }
>
> What I am trying to accomplish is determining if I have the file
> already in the database, of if the file is different than the one
> already stored in couch.  It would be nice to keep it with the
> attachment instead of creating a parallel structure to hold the
> information.
>
> Regards,
>
> Jeff
>



-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message