CouchDB Attaching Files

You can attached file in couchDB. If you want to attach a file to the document then all you need to do is send a PUT request to the server. The file contains :-
1. Name
2. MIME type
3. Number of bytes

Syntax

$ curl -vX PUT http://127.0.0.1:5984/database-name/database-id
/filename?rev=document rev_id --data-binary @filename -H "Content-Type:
type of the content"


-H:-Used to mention the content type of the file
--data-binary@:-Tells cURL to read a file’s contents into the HTTP request body.


Example :

We have to attach a file named LFC.jpg, to the document with id johndoe in the database named contacts by sending PUT request to CouchDB.

First you have to get the revision ID of the document. If you don't know _rev, you can find yourself in the document using the command below. Now after getting the revision ID, using the _rev value, send the PUT request to the CouchDB server as shown below.

Find revision ID
$ curl -X GET http://127.0.0.1:5984/contacts/johndoe
{
"_id" : "johndoe",
"_rev" : "2-04d8eac1680d237ca25b68b36b8899d3 "
}
-----------------------------------------------------
-----------------------------------------------------
Attaching Files
$ curl -vX PUT http://127.0.0.1:5984/contacts/johndoe/LFC.jpg?rev=1-
967a00dff5e02add41819138abb3284d --data-binary @LFC.jpg -H "ContentType:
image/jpg"



Verification :

If you want to verify whether the document is attached or not, you can verify by fetching the contents of the document.

$ curl -X GET http://127.0.0.1:5984/contacts/johndoe
{
"_id": "johndoe",
"_rev": "2-4705a219cdcca7c72aac4f623f5c46a8",
"_attachments": {
"LFC.jpg": {
"content_type": "image/jpg",
"revpos": 2,
"digest": "md5-9Swz8jvmga5mfBIsmCxCtQ==",
"length": 91408,
"stub": true
}
}
}



Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

pHqghUme
-1 OR 2+727-727-1=0+0+0+1 --

pHqghUme
-1 OR 3+727-727-1=0+0+0+1 --

pHqghUme
-1 OR 3*2<(0+5+727-727) --

pHqghUme
-1 OR 3*2>(0+5+727-727) --

pHqghUme
-1 OR 2+308-308-1=0+0+0+1

pHqghUme
-1 OR 3+308-308-1=0+0+0+1

pHqghUme
-1 OR 3*2<(0+5+308-308)

pHqghUme
-1 OR 3*2>(0+5+308-308)

pHqghUme
-1' OR 2+640-640-1=0+0+0+1 --

pHqghUme
-1' OR 3+640-640-1=0+0+0+1 --

pHqghUme
-1' OR 3*2<(0+5+640-640) --

pHqghUme
-1' OR 3*2>(0+5+640-640) --

pHqghUme
-1' OR 2+277-277-1=0+0+0+1 or 'BiOWnj3k'='

pHqghUme
-1' OR 3+277-277-1=0+0+0+1 or 'BiOWnj3k'='

pHqghUme
-1' OR 3*2<(0+5+277-277) or 'BiOWnj3k'='

pHqghUme
-1' OR 3*2>(0+5+277-277) or 'BiOWnj3k'='

pHqghUme
-1" OR 2+865-865-1=0+0+0+1 --

pHqghUme
-1" OR 3+865-865-1=0+0+0+1 --

pHqghUme
-1" OR 3*2<(0+5+865-865) --

pHqghUme
-1" OR 3*2>(0+5+865-865) --

pHqghUme
if(now()=sysdate(),sleep(15),0)

pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

pHqghUme
-1; waitfor delay '0:0:15' --

pHqghUme
-1); waitfor delay '0:0:15' --

pHqghUme
1 waitfor delay '0:0:15' --

pHqghUme
GnWLRSZh'; waitfor delay '0:0:15' --

pHqghUme
-5 OR 368=(SELECT 368 FROM PG_SLEEP(15))--

pHqghUme
-5) OR 69=(SELECT 69 FROM PG_SLEEP(15))--

pHqghUme
-1)) OR 681=(SELECT 681 FROM PG_SLEEP(15))--

pHqghUme
WmZQalfy' OR 835=(SELECT 835 FROM PG_SLEEP(15))--

pHqghUme
TnsRHfhP') OR 994=(SELECT 994 FROM PG_SLEEP(15))--

pHqghUme
Dv24GmNU')) OR 945=(SELECT 945 FROM PG_SLEEP(15))--

pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

pHqghUme
1'"

pHqghUme

pHqghUme
@@8qeJ6

pHqghUme
555

pHqghUme
555

pHqghUme
555