Appending Files utilizing cURL
You can join documents to CouchDB simply like email. The record contains metadata like name and incorporates its MIME type, and the quantity of bytes the connection contains. To connect records to a report you need to send PUT solicitation to the worker. Following is the sentence structure to connect records to the archive −
$ 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"
The solicitation has different alternatives that are clarified beneath.
- - information binary@ − This alternative advises cURL to add a record's substance to the HTTP demand body.
- - H − This alternative is utilized to specify the substance kind of the record we will transfer.
Model
Allow us to append a record named boy.jpg, to the archive with id 001, in the information base named my_database by sending PUT solicitation to CouchDB. Prior to that, you need to get the information of the record with id 001 to get its present fire up id as demonstrated beneath.
$ curl -X GET http://127.0.0.1:5984/my_database/001
{
"_id": "001",
"_rev": "1-967a00dff5e02add41819138abb3284d"
}
Presently utilizing the _rev esteem, send the PUT solicitation to the CouchDB worker as demonstrated underneath.
$ curl -vX PUT http://127.0.0.1:5984/my_database/001/boy.jpg?rev=1-
967a00dff5e02add41819138abb3284d --data-binary @boy.jpg -H "ContentType:
image/jpg"
Verification
To confirm whether the connection is transferred, bring the archive content as indicated below−
$ curl -X GET http://127.0.0.1:5984/my_database/001
{
"_id": "001",
"_rev": "2-4705a219cdcca7c72aac4f623f5c46a8",
"_attachments": {
"boy.jpg": {
"content_type": "image/jpg",
"revpos": 2,
"digest": "md5-9Swz8jvmga5mfBIsmCxCtQ==",
"length": 91408,
"stub": true
}
}
}
Appending Files utilizing Futon
Transfer Attachment
Utilizing this choice, you can transfer another connection, for example, a record, picture, or archive, to the data set. To do as such, click on the Upload Attachment button. A discourse box will show up where you can pick the document to be transferred. Select the document and snap on the Upload button.
The record transferred will be shown under _attachments field. Later you can see the record by tapping on it.