PouchDB Retrieve Attachment
The getAttachment() method is used to retrieve an attachment from PouchDB. This method always returns blob or buffer objects.
You have to pass the document id and attachment id to use this method. This method also accepts an optional callback function.
Retrieve Attachment Example
Let's use getAttachment() method to retrieve an attachment attachment_1.txt from the document "002" from the database named "Last_Database".
Retrieve Attachment from a Remote Document
You can also retrieve an attachment from a remotely stored server (CouchDB). You just have to pass the path to the database in CouchDB, which contains the document that that you want to read.
We have a database name "employees" stored on the CouchDB server.
Click on the "employees" database. You will see the documents within the database.
You can see a document having id "001". Click on the id and you will find the attachment.
You can see it by using Node.js command prompt: