Kwasi, just as a suggestion, set $this->_attachments = new stdClass() at the constructor - otherwise you'll miss attachments .. if you're using more then one
Regards Stefan On Thu, Sep 22, 2011 at 5:44 AM, Kwasi Gyasi - Agyei <[email protected]> wrote: > 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 [email protected] > 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 > >
