Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 965027394 for ; Thu, 22 Sep 2011 08:06:37 +0000 (UTC) Received: (qmail 47264 invoked by uid 500); 22 Sep 2011 08:06:36 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 47184 invoked by uid 500); 22 Sep 2011 08:06:35 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 47172 invoked by uid 99); 22 Sep 2011 08:06:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2011 08:06:35 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of matheis.stefan@googlemail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-iy0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2011 08:06:28 +0000 Received: by iahk25 with SMTP id k25so3970968iah.11 for ; Thu, 22 Sep 2011 01:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=csJjj7eN4nUcngvYQTpTycQqhyKtSExIBItzwUxwID4=; b=AJdyWn4U608e46Ze2DFIHnWJ+s/sEmpF7xz6cw+S4IdfYkpaq6IXKLsKi2t1Ilw1gK LWCYYRnS/YoRy0SZgR8WtMiDVM4sRVP3odUpAmyal5V1WTCfAUkcVa3oEj1K79Pw+TYm D5zM1t+DLPrrS65xIZzutt4/cEx6O6mXnsn1Q= MIME-Version: 1.0 Received: by 10.43.133.133 with SMTP id hy5mr1660140icc.82.1316678767865; Thu, 22 Sep 2011 01:06:07 -0700 (PDT) Received: by 10.42.228.134 with HTTP; Thu, 22 Sep 2011 01:06:07 -0700 (PDT) In-Reply-To: References: <350596FD-77B7-4257-814A-5B555DB1105D@4things.co.za> <8FF9873D-1772-4B1E-85C2-976B7EDE4AB7@couchbase.com> Date: Thu, 22 Sep 2011 10:06:07 +0200 Message-ID: Subject: Re: CouchDB Inline Attachment version 1.1.0 From: Stefan Matheis To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Kwasi, just as a suggestion, set $this->_attachments =3D 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 wrote: > Thanks :) > > All working now, included code below for whoever runs into the same blund= er. > > (PHP) inline attachment dictionary. > > =A0 =A0 =A0 =A0/** > =A0 =A0 =A0 =A0 * > =A0 =A0 =A0 =A0 * This is used to add an inine attachment to a document. > =A0 =A0 =A0 =A0 * > =A0 =A0 =A0 =A0 * @param String $attachmentName > =A0 =A0 =A0 =A0 * @param String $attachmentPath > =A0 =A0 =A0 =A0 */ > =A0 =A0 =A0 =A0public function attachment( $attachmentName, $attachmentPa= th ) > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$attachmentContent =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D trim( file_get_contents( $atta= chmentPath ) ); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$attachmentBase64Encoded =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =3D base64_encode( $attachmentContent )= ; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$this->_attachments =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=3D new stdClass(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$this->_attachments->$attachmentName =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =3D new stdClass(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$this->_attachments->$attachmentName->cont= ent_type =3D "text/plain"; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$this->_attachments->$attachmentName->data= =A0 =A0 =A0 =A0 =3D $attachmentBase64Encoded; > > =A0 =A0 =A0 =A0} > > > 4Things > Multimedia and Communication | Property | Entertainment > Kwasi Owusu Gyasi - Agyei > > cell =A0 =A0 =A0 =A0(+27) (0) 76 466 4488 > website www.4things.co.za > email =A0 =A0 kwasi.gyasiagyei@4things.co.za > skype =A0 =A0kwasi.gyasiagyei > role =A0 =A0 =A0 =A0Developer.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": >>> =A0 =A0 {"content_type":"text\/plain", >>> =A0 =A0 =A0 "data":"aGVsbG8gd29ybGQ=3D" >>> =A0 =A0 } >>> } ] >> >> _attachments is a dictionary, not an array. This should be: >> >> "_attachments=94:{ >> "test": >> =A0 =A0 {"content_type":"text\/plain", >> =A0 =A0 =A0 "data":"aGVsbG8gd29ybGQ=3D" >> =A0 =A0 } >> } >> >> See >> >> =97Jens > >