0

I've installed couchdb and mingw64 on my windows 10, I can use futon to operate my couch db, no problem. Then I tried command line using curl. I used curl to create database named "my_database", I can query it using "GET":

$ curl -X GET http://localhost:5984/my_database/002
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
100    81  100    81    0     0    397      0 --:--:-- --:--:-- --:--:--   397{"_id":"002","_rev":"1-5e653801ca3cefde8abb6492ae3bcbcd","name":"mesi","age":23}

But I cannot do any data update, seems my curl syntax had problem:

$ curl -X PUT http://127.0.0.1:5984/my_database/002/msg.jpg?res=1-5e653801ca3cefde8abb6492ae3bcbcd --data-binary @/e/msg.jpg -H "ContentType:image/jpg"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
 14  910k  100    58   14  128k     58   128k  0:00:07 --:--:--  0:00:07  125M{"error":"conflict","reason":"Document update conflict."}

I know the jpg file is there:

$ ls /e/msg.jpg
/e/msg.jpg

Why I cannot update the jpg document as attachement? I guess I might have some syntax error using curl or couchdb, but how to fix it?

Using futon_db: created document, but what's the URL resource name of it?

1 Answer 1

1

Whenever you update a document/Attachment in CouchDB, you need to specify the revision (otherwise it cause conflicts). I guess that you only forgot to write rev properly (you wrote res).

Syntax taken from this question :

curl -vX PUT http://localhost:5984/YOUR_DB/YOUR_DOCUMENT/YOUR_ATTACHMENT.jpg?rev=REVISION_OF_THE_DOCUMENT_BEFORE_UPLOADING_AN_ATTACHMENT --data-binary @FILE_ON_THE_DISK.JPG -H "Content-Type: image/jpg"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.