/** * Add an attachment to the document by file system or HTTP path (URI) * * We'll try to figure out the name and content type of the attachment for you * but you can optionally provide that info. * * NOTE: I tried installing the Fileinfo module via PECL but it wasn't cooperating. * So, I make a decent attempt to grab the right content type etc... but it can be * faulty. So if this gives you any trouble use $this->addAttachment() instead. * * @param string $pathToFile Path to the file you want to attach * @param string $contentType Content-Type of the attachment * @param string $name The name of the attachment (optional) * * @return array The attachment being sent to CouchDB */ public function addAttachmentByPath($pathToFile, $contentType = null, $name = null) { $info = Duckk_CouchDB_Util::getAttachmentInfo($pathToFile); if ($contentType !== null) { $info['content_type'] = $contentType; } // if $attachmentName is given then use that as opposed to $info['basename'] if ($name === null) { $name = $info['basename']; } return $this->addAttachment($name, $info['data'], $info['content_type']); }
public function replicate($sourceDBName, $targetDB) { $data = array('source' => $sourceDBName, 'target' => $targetDB); $status = $this->connection->post(Duckk_CouchDB_Util::makeDatabaseURI('/_replicate'), json_encode($data)); return $status; }