On Tue, Feb 24, 2009 at 04:51:08PM -0500, Paul Davis wrote: > That hadn't occurred to me. I kinda liked the attachments via > multipart mime so i was more forcing everything else into that format. > At the moment I can't decide which form I prefer. I definitely see > sticking to JSON being easier to parse all around, though.
Even if you could read MIME multipart directly using XHR, to get a document complete with its attachments, you'd end up with binary (non-Unicode) strings in your Javascript. Ecma-262 says that Strings don't have to be valid Unicode. However CouchDB requires attachment uploads to be base64-encoded. Would I be right to say this is because of a JSON restriction, rather than a Javascript one? CouchDB dodges this at present, since you can't download a document together with its attachments. I don't suppose that much attachment processing takes place in Javascript anyway; in normal cases the Javascript creates a URL from the attachment name, which the user clicks on to download or view the attachment, without JS ever seeing the body. Regards, Brian.
