Return-Path: Delivered-To: apmail-incubator-couchdb-dev-archive@locus.apache.org Received: (qmail 320 invoked from network); 23 May 2008 16:14:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 May 2008 16:14:45 -0000 Received: (qmail 40676 invoked by uid 500); 23 May 2008 16:14:46 -0000 Delivered-To: apmail-incubator-couchdb-dev-archive@incubator.apache.org Received: (qmail 40652 invoked by uid 500); 23 May 2008 16:14:46 -0000 Mailing-List: contact couchdb-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-dev@incubator.apache.org Received: (qmail 40641 invoked by uid 99); 23 May 2008 16:14:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 May 2008 09:14:46 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cmlenz@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 23 May 2008 16:13:50 +0000 Received: (qmail invoked by alias); 23 May 2008 16:14:11 -0000 Received: from dslb-084-058-084-025.pools.arcor-ip.net (EHLO [192.168.1.200]) [84.58.84.25] by mail.gmx.net (mp007) with SMTP; 23 May 2008 18:14:11 +0200 X-Authenticated: #2618757 X-Provags-ID: V01U2FsdGVkX1+ptUZOjuepbemKfobLuoRsJVWT5bAPmZYrThHm+0 lmNmyN2xSlf5OR Message-Id: From: Christopher Lenz To: couchdb-dev@incubator.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Attachment management in Futon Date: Fri, 23 May 2008 18:14:11 +0200 X-Mailer: Apple Mail (2.919.2) X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org Hey folks, I've started playing with attachment support in Futon. As Futon is a purely client-side application this is of course tricky (or actually impossible), and it'll need some kind of hook on the server side. I have two separate ideas on how this might be enabled, each with its own advantages and disadvantages: 1. POST /_utils/upload/ This would be a special URL in CouchDB that would only exist to support Futon. It would take a multipart/form-data POST request, extra a file upload, and respond with a JSON representation of that upload, with the content base64 encoded: handle_upload_request(Req, 'POST') -> Form = mochiweb_multipart:parse_form(Req), {Name, {ContentType, _}, Content} = proplists:get_value("file", Form), Json = {obj, [ {name, Name}, {type, ContentType}, {content, couch_util:encodeBase64(Content)} ]}, Body = "", {ok, Req:ok({"text/html", Body})}; The JSON needs to be wrapped in HTML, because AJAX file uploads need to go through a separate hidden