Jens,
A bit of clarification on my behalf. I'm doing a POST using the following
command:
curl --data @nonBreak.json http://localhost:5984/source_data --header
"Content-Type: application/json"
The issue is embedding base64'd attachment in the JSON. I would prefer to
refrain from using MIME as other data needs to be sent with the attachment.
I've attempted to POST with two different types of base64'd attachments. I've
attempted to use the standard conversion made available by apache commons
codec. This (unfortunately) produces a string with line breaks. CouchDB
documentation states that there can be no line breaks (I assume due to the
syntax of JSON and the result not being parsed correctly). I looked into used
the base64.encodeBase64URLSafeString in commons codec which is supposed to
generate a string with no line breaks and url safe characters. I'm beginning
to think the latter is not supported.
I'm looking into removing newline characters from the generated base64'd
attachment, however when I scan the string (java:
content.replace((\r\n|\n|\r),"")) nothing appears to be removed from the string.
Does CouchDB support url-safe base64Encoded strings? If not (and this may be
more of a java related issue) are there any libraries that will remove line
breaks in base encoded strings?
Lastly, about your P.S. If you go to http://couchdb.apache.org/ and look at the
Download Section. There label says Windows(R15B).
-----Original Message-----
From: Jens Alfke [mailto:[email protected]]
Sent: Tuesday, August 21, 2012 12:03 PM
To: [email protected]
Subject: Re: Base64 attachment via Futon
On Aug 21, 2012, at 8:22 AM, Stephen Ohimor <[email protected]> wrote:
> Context: I'm posting a document with an attachment. The attachment is a
> Base64 url-safe encoded string. I am posting to a local CouchDB server
> (R15B) via the Futon Interface.
Why use that API? My understanding is that Futon's API is considered internal,
and not supported.
It's quite easy to upload attachments using a regular PUT/POST to the document
URL. You can embed the base64'd attachment in the JSON, or you can post in MIME
multipart format and send the attachment raw.
-Jens
PS: Also, I just noticed you said R15B - that's the version of *Erlang*, not of
CouchDB. To see the CouchDB version, GET /.