You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Jens Alfke <je...@couchbase.com> on 2011/09/16 06:23:11 UTC

What fields in _attachments are official?

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 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

Re: What fields in _attachments are official?

Posted by Filipe David Manana <fd...@apache.org>.
On Thu, Sep 15, 2011 at 9:23 PM, Jens Alfke <je...@couchbase.com> 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."