Disclaimer: this particular issue is caused by me trying to be lazy and is not an issue I would have in production.
I'm trying to access a view from a script in my browser. To avoid CORS issues (which it seems CouchBase does not support), I was trying to load my HTML and JavaScript files into CouchBase and then try and read them back directly from the browser, but I can't get this to work.
When I save the object into CouchBase, it (understandably) fails to recognize it as valid JSON and does some kind of compression/encryption/translation on it:
Then, when I try and recover the document, it gives me back a JSON version of the "compressed" form (it's described as base64 encoding, but I think it's base64 of some compression, but it's hard to tell):
HTTP/1.1 200 OK
X-Couchbase-Meta: {"id":"webui","rev":"2-00008c4196f76c460000000000000000","att_reason":"invalid_json","expiration":0,"flags":0,"type":"base64"}
Server: MochiWeb/1.0 (Any of you quaids got a smint?)
Date: Thu, 04 Jul 2013 14:01:02 GMT
Content-Type: application/json
Content-Length: 10
Cache-Control: must-revalidate
"Um9vdA=="
I've googled around a bit, and can't find any CouchBase 2 compliant way of "decrypting" this; I can't even find a description of what the exact algorithm is. But since I want to be able to read it from the browser I can't do anything at all clever. The only references I could find to this problem referenced the CouchDB "attachment" feature, but this is not supported in CouchBase 2:
{"error":"bad_request","reason":"attachments not supported in Couchbase"}
I tried specifying "Accept:" headers to see if that would force it to recognize I wanted text/plain or text/html but it happily returned me application/json. I feel there should be some sort of option or URL or something that enables me to get back what I put in, but I can't find it. Can anyone help me?
Thanks,
Gareth