incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Moritz Post <>
Subject Create Content-MD5 hash
Date Tue, 27 Sep 2011 13:29:50 GMT
Hallo CouchDB

I am trying to validate the integrity of data i upload to the couchdb.
Therefore i provide a valid MD5 hash alongside my PUT request. From what i
have gathered this md5 has to be base64 encoded. My problem is that i am not
able to create a valid hash. All i get is:

{"error":"content_md5_mismatch","reason":"Possible message corruption."}

I am currently experimenting with a CURL based approach but will need
to incorporate the hash creation into a java program later. Here is what is
did do create the md5 hash:

$ md5sum test.json
4bf3aac171ded1679d3501ccbd3e0d85  test.json
$ echo 4bf3aac171ded1679d3501ccbd3e0d85 | base64

So i have a hash value and now use it in my PUT request (verbose output):

$ curl -X PUT -H "Content-MD5: NGJmM2FhYzE3MWRlZDE2NzlkMzUwMWNjYmQzZTBkODUK"
-H "Content-Type: application/json" -v -d @test.json
* About to connect() to port 5984 (#0)
*   Trying connected
* Connected to ( port 5984 (#0)
* Server auth using Basic with user 'admin'
> PUT /test/doc/test.json?rev=3-dd5bf35d8e95a0ccc5e2a1e0adf26ffb HTTP/1.1
> User-Agent: curl/7.21.3 (i686-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o
zlib/ libidn/1.18
> Host:
> Accept: */*
> Content-Type: application/json
> Content-Length: 19
< HTTP/1.1 400 Bad Request
< Server: CouchDB/1.0.2 (Erlang OTP/R14B)
< Date: Tue, 27 Sep 2011 13:23:38 GMT
< Content-Type: text/plain;charset=utf-8
< Content-Length: 73
< Cache-Control: must-revalidate
{"error":"content_md5_mismatch","reason":"Possible message corruption."}
* Connection #0 to host left intact
* Closing connection #0

I am running a couchdb 1.0.3.

The question is: how to properly create a md5 hash that validates the

Additionally i would like to know if it is only possible to validated
attachment uploads or is it also possible to validated the uploaded json
documents one creates in the couchdb?

Thank you
Moritz Post

Moritz Post
Tel: +49-721-66-47-33-33
Fax: +49-721-66-47-33-29
========================= Legal Disclaimer =================================
According to Section 80 of the German Corporation Act
Innoopract Informationssysteme GmbH must indicate the following information:
Address: Stephanienstrasse 20, 76133 Karlsruhe Germany
General Manager: Jochen Krause
Registered Office: Commercial Register Mannheim HRB 107883

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