Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 1997093

Browse files
citychadchadbean
authored andcommitted
Add method to support retrieving file attachments
1 parent c80f250 commit 1997093

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/Doctrine/CouchDB/CouchDBClient.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,24 @@ public function compactDatabase()
560560
return $response->body;
561561
}
562562

563+
/**
564+
* Retrieve specific binary attachment data.
565+
*
566+
* @param string $id
567+
* @param string $fileName
568+
* @return string
569+
*/
570+
public function getAttachment($id, $fileName) {
571+
$attachmentPath = '/' . $this->databaseName . '/' . $id . '/' . $fileName;
572+
$response = $this->httpClient->request('GET', $attachmentPath, null, true);
573+
574+
if ($response->status != 200) {
575+
throw HTTPException::fromResponse($attachmentPath, $response);
576+
}
577+
578+
return $response->body;
579+
}
580+
563581
/**
564582
* POST /db/_compact/designDoc
565583
*

0 commit comments

Comments
 (0)