incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kwasi Gyasi - Agyei <kwasi.gyasiag...@4things.co.za>
Subject Re: CouchDB Inline Attachment version 1.1.0
Date Thu, 22 Sep 2011 03:44:11 GMT
Thanks :)

All working now, included code below for whoever runs into the same blunder.

(PHP) inline attachment dictionary.

	/**
	 * 
	 * This is used to add an inine attachment to a document.
	 * 
	 * @param String $attachmentName
	 * @param String $attachmentPath
	 */
	public function attachment( $attachmentName, $attachmentPath )
	{
		$attachmentContent                                 = trim( file_get_contents( $attachmentPath
) );
		$attachmentBase64Encoded                           = base64_encode( $attachmentContent );
		$this->_attachments                                = new stdClass();
		$this->_attachments->$attachmentName               = new stdClass();
		$this->_attachments->$attachmentName->content_type = "text/plain";
		$this->_attachments->$attachmentName->data         = $attachmentBase64Encoded;
		
	}


4Things
Multimedia and Communication | Property | Entertainment
Kwasi Owusu Gyasi - Agyei

cell        (+27) (0) 76 466 4488
website www.4things.co.za
email     kwasi.gyasiagyei@4things.co.za
skype    kwasi.gyasiagyei
role        Developer.Designer.Software Architect


On 21 Sep 2011, at 11:50 PM, Jens Alfke wrote:

> 
> On Sep 21, 2011, at 1:46 PM, Kwasi Gyasi - Agyei wrote:
> 
>> "_attachments":[
>> {"test":
>>     {"content_type":"text\/plain",
>>       "data":"aGVsbG8gd29ybGQ="
>>     } 
>> } ]
> 
> _attachments is a dictionary, not an array. This should be:
> 
> "_attachments”:{
> "test":
>     {"content_type":"text\/plain",
>       "data":"aGVsbG8gd29ybGQ="
>     } 
> }
> 
> See <http://wiki.apache.org/couchdb/HTTP_Document_API#Inline_Attachments>
> 
> —Jens


Mime
View raw message