Morris
Morris

Reputation: 142

get a CouchDB attachment and show it on a html page

I want to show in my html page an image that I've attached in a document on couchdb. How I can do this using javascript (jquery)?

I solved using

$.couch.db("mydb").view(...)

to obtain the id of document that I'm interesting. And

$.couch.db("mydb").openDoc(id, {...})

to obtain the image coded in base64. After that I put this base64's code in tag

<img src="data:image/jpg; base64, ...">

Upvotes: 0

Views: 748

Answers (1)

Anthony
Anthony

Reputation: 12736

Actually you can do this by adding img tag:

<img src="http://somehost/somedatabase/document/attachment">

Upvotes: 2

Related Questions