incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <>
Subject Re: What fields in _attachments are official?
Date Fri, 16 Sep 2011 04:44:19 GMT
On Thu, Sep 15, 2011 at 9:23 PM, Jens Alfke <> wrote:
> Which fields of an attachment structure in a document are part of the API, and which
are subject to change?
> The wiki only talks about “content_type”, “length”, “data” and “stub”.
> But in real life, I also see “digest” and “revpos”.
> The “digest” field in particular is very useful — I’m working on digital signatures
for documents, and since attachments should be considered part of the document, they need
to be signed along with

That digest might surprise you in some cases. The detail is that the
digest can be a digest of the attachment data in compressed form, not
in the form you uploaded it. When you upload attachments to Couch, if
their MIME type is configured as compressible in the .ini
configuration, Couch will compress the attachment while storing it
into the database file, together with the md5 calculated after the
compression is applied.

By default only MIME types that match text/* and application/xml are
compressed, but this can be changed.

You can know if an attachment is compressed by GETing a doc with
?att_encoding_info=true - it will add a filed "encoding": "gzip" if
the attachment is compressed.

 it. If the _attachments dictionary contains a digest, then signing it
effectively includes the attachment in the signature. But I don’t want
to rely on this if the field might change format or go away in a
future version of CouchDB.
> —Jens

Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

View raw message