Reputation: 1928
I need to download, edit and upload (via HTTP PUT) binary blobs to CouchDB (as attachments) from a browser javascript CouchApp.
My google-fu fails me to find anything even remotely similar to this :/
Current solution involves using Silverlight, and I wish to go plain-js on modern browsers (Safari, Mobile Safari (iOS), IE 9, Opera 11 etc)
There is a solution for uploading data in Chrome ( Post binary data cross domain in javascript ) , but I don't want to stick to that particular browser.
Upvotes: 5
Views: 2246
Reputation: 73702
Javascript is a bit inconvenient for dealing with binary data, but it should still be possible.
The simplest way to do this is to use CouchDB's base64 version of the attachments. You can get attachments inline in a document, and then store them back as inline attachments.
You can use any Javascript base64 library to decode them in the browser. CouchDB includes one as part of its Futon application. You can retrieve it from /_utils/script/base64.js
.
Upvotes: 4