3 ms·
Yeah it doesn't make a lot of sense. I feel like the author must be doing something wrong with CouchDB in the first place if his binary uploads are being conver
by aphextron 10y ago
Yeah it doesn't make a lot of sense. I feel like the author must be doing something wrong with CouchDB in the first place if his binary uploads are being converted to UTF-8. Not to mention that that kind of thing should always be checked application side anyways.
- daenney 10y agoIf you want to place binary data in CouchDB that's entirely possible. However, you have to create a document and then add an attachment to it. Attachments themselves can have multiple revisions. When PUTing[1] the attachment the appropriate Content-Type header is required to be set. If both of these things are done properly I see no obvious reason as to why they'd run into the encoding issue mentioned. Which makes me suspect it's not properly using the attachment feature or not correctly setting the MIME type. Or they're doing something weird when grabbing the binary data from the user, like not using FileReader.readAsArrayBuffer()[2] from their JS code and instead getting it as text. readAsArrayBuffer is specifically designed to deal with binary data, usually used with images in web context. [1]: http://docs.couchdb.org/en/2.0.0/api/document/attachments.html http://docs.couchdb.org/en/2.0.0/api/document/attachments.ht... [2]: https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsArrayBuffer https://developer.mozilla.org/en-US/docs/Web/API/FileReader/...