|
@@ 1362-1375 (lines=14) @@
|
| 1359 |
|
* @retval string The document's revision. |
| 1360 |
|
* @see http://docs.couchdb.org/en/latest/api/document/attachments.html#db-doc-attachment |
| 1361 |
|
*/ |
| 1362 |
|
public function getAttachmentInfo($dbName, $fileName, $path, $docId, $rev = NULL) { |
| 1363 |
|
$this->validateDocPath($path, TRUE); |
| 1364 |
|
$this->validateAndEncodeDocId($docId); |
| 1365 |
|
|
| 1366 |
|
$path = "/".rawurlencode($this->prefix.$dbName)."/".$path.$docId."/".$fileName; |
| 1367 |
|
|
| 1368 |
|
$request = new Request(Request::HEAD_METHOD, $path); |
| 1369 |
|
|
| 1370 |
|
// In case we want retrieve a specific document revision. |
| 1371 |
|
if (!empty($rev)) |
| 1372 |
|
$request->setQueryParam("rev", (string)$rev); |
| 1373 |
|
|
| 1374 |
|
return $this->send($request); |
| 1375 |
|
} |
| 1376 |
|
|
| 1377 |
|
|
| 1378 |
|
/** |
|
@@ 1389-1402 (lines=14) @@
|
| 1386 |
|
* @see http://docs.couchdb.org/en/latest/api/document/attachments.html#http-range-requests |
| 1387 |
|
* @todo Add support for Range request, using header "Range: bytes=0-12". |
| 1388 |
|
*/ |
| 1389 |
|
public function getAttachment($dbName, $fileName, $path, $docId, $rev = NULL) { |
| 1390 |
|
$this->validateDocPath($path, TRUE); |
| 1391 |
|
$this->validateAndEncodeDocId($docId); |
| 1392 |
|
|
| 1393 |
|
$path = "/".rawurlencode($this->prefix.$dbName)."/".$path.$docId."/".$fileName; |
| 1394 |
|
|
| 1395 |
|
$request = new Request(Request::GET_METHOD, $path); |
| 1396 |
|
|
| 1397 |
|
// In case we want retrieve a specific document revision. |
| 1398 |
|
if (!empty($rev)) |
| 1399 |
|
$request->setQueryParam("rev", (string)$rev); |
| 1400 |
|
|
| 1401 |
|
return $this->send($request)->getBody(); |
| 1402 |
|
} |
| 1403 |
|
|
| 1404 |
|
|
| 1405 |
|
/** |
|
@@ 1444-1454 (lines=11) @@
|
| 1441 |
|
* @param[in] string $rev The document's revision. |
| 1442 |
|
* @see http://docs.couchdb.org/en/latest/api/document/attachments.html#delete--db-docid-attname |
| 1443 |
|
*/ |
| 1444 |
|
public function deleteAttachment($dbName, $fileName, $path, $docId, $rev) { |
| 1445 |
|
$this->validateDocPath($path, TRUE); |
| 1446 |
|
$this->validateAndEncodeDocId($docId); |
| 1447 |
|
|
| 1448 |
|
$path = "/".rawurlencode($this->prefix.$dbName)."/".$path.$docId."/".rawurlencode($fileName); |
| 1449 |
|
|
| 1450 |
|
$request = new Request(Request::DELETE_METHOD, $path); |
| 1451 |
|
$request->setQueryParam("rev", (string)$rev); |
| 1452 |
|
|
| 1453 |
|
return $this->send($request); |
| 1454 |
|
} |
| 1455 |
|
|
| 1456 |
|
//!@} |
| 1457 |
|
|