Hi Robert Thanks for the reply. Using -n does produce a different echo output but it does not produce a hash consumable by the couchdb: $ echo -n 4bf3aac171ded1679d3501ccbd3e0d85 | base64 NGJmM2FhYzE3MWRlZDE2NzlkMzUwMWNjYmQzZTBkODU= $ echo 4bf3aac171ded1679d3501ccbd3e0d85 | base64 NGJmM2FhYzE3MWRlZDE2NzlkMzUwMWNjYmQzZTBkODUK Using the hash with the = at the end i still get the response: {"error":"content_md5_mismatch","reason":"Possible message corruption."} Greets Moritz On Tue, Sep 27, 2011 at 4:19 PM, Robert Newson wrote: > try > > echo -n 4bf3aac171ded1679d3501ccbd3e0d85 | base64 > > as echo includes a new line unless you use -n. > > B. > > On 27 September 2011 14:29, Moritz Post wrote: > > 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 > > NGJmM2FhYzE3MWRlZDE2NzlkMzUwMWNjYmQzZTBkODUK > > > > 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 > > > http://localhost:5984/test/doc/test.json?rev=3-dd5bf35d8e95a0ccc5e2a1e0adf26ffb > > * About to connect() to 192.168.6.168 port 5984 (#0) > > * Trying 192.168.6.168... connected > > * Connected to 192.168.6.168 (192.168.6.168) 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/1.2.3.4 libidn/1.18 > >> Host: 192.168.6.168:5984 > >> Accept: */* > >> Content-MD5: NGJmM2FhYzE3MWRlZDE2NzlkMzUwMWNjYmQzZTBkODUK > >> 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 192.168.6.168 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 > > upload. > > > > 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 > > EclipseSource > > Email: mpost@eclipsesource.com > > Tel: +49-721-66-47-33-33 > > Fax: +49-721-66-47-33-29 > > http://www.eclipsesource.com/ > > ========================= 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 > > > ============================================================================ > > > -- ----------------------------------- Moritz Post EclipseSource Email: mpost@eclipsesource.com Tel: +49-721-66-47-33-33 Fax: +49-721-66-47-33-29 http://www.eclipsesource.com/ ========================= 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 ============================================================================