[
https://issues.apache.org/jira/browse/COUCHDB-1705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14273023#comment-14273023
]
Alexander Shorin commented on COUCHDB-1705:
-------------------------------------------
That's for case when you're going to make an attachment. If I have a update
function which takes some text, parses it and generates a document you need
access to raw req.body data, not base64-encoded.
I see the following solutions here:
1. Provide additional field {{bodyB64}} with base64 encoded body, handle body
serialization crash correctly and set it as {{null}} in that case.
Pro: we avoid crash for binary data, keep access to raw text and are able to
easily put it into attachments with no serialization.
Cons: this boosts commands size for query server for 2.3 times.
2. Provide base64 helper for query server and always encode body with base64
Pro: no much overhead for passed data around (just 30%).
Cons: we breaking all existed functions which uses {{req.body}} for some way.
3. Try to be smart and encode only those payloads which are uses to be binary.
We have at least to MIME types (application/json and
application/www-formencode) which additionally get parsed into friendly
structure. +Provide base64 helper.
Pro: at most preserve backward compatibility and provide helper to deal with
b64encoded data in case of our failure.
Cons: need a bit more work around.
> Update Function does not parse multipart/form-data
> --------------------------------------------------
>
> Key: COUCHDB-1705
> URL: https://issues.apache.org/jira/browse/COUCHDB-1705
> Project: CouchDB
> Issue Type: Bug
> Components: JavaScript View Server
> Affects Versions: 1.2.1, 1.6.1
> Reporter: Anthony Ananich
> Attachments: base64.patch
>
>
> I have a design doc and update handler.
> {quote}
> function(doc, req) {
> log(req);
> var newdoc = {};
> ...
> return [newdoc, \{
> code: 200,
> body: req.uuid
> }];
> }
> {quote}
> I made a HTML file with the following form
> {quote}
> <form action="http://localhost:5984/db/_design/app/_update/crashreport"
> method="POST" enctype="multipart/form-data">
> <input type="text" name="classname"/><br>
> <input type="Submit">
> </form>
> {quote}
> In the log file I can see that POST request body exists, but was not parsed:
> {quote}
> { "body" : "------WebKitFormBoundaryE6xRBni3g8MNw14P\r\nContent-Disposition:
> form-data;
> name=\"classname\"\r\n\r\nABC\r\n------WebKitFormBoundaryE6xRBni3g8MNw14P--\r\n",
> "form" : { },
> ...
> {quote}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)