You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by stevebest <gi...@git.apache.org> on 2017/03/20 06:07:35 UTC

[GitHub] couchdb-nano issue #36: Streamable multipart attachments are not supported

GitHub user stevebest opened an issue:

    https://github.com/apache/couchdb-nano/issues/36

    Streamable multipart attachments are not supported

    Consider a scenario when you want to upload a document and several attachments to a CouchDB in a single request - a typical example would be uploading a "Couchapp": a design doc with multiple HTML/JS/CSS attachments. This scenario is [supported by CouchDB API](http://docs.couchdb.org/en/1.6.1/api/document/common.html?highlight=multipart/related#creating-multiple-attachments) using `Content-Type: multipart/related` request. Furthermore, you could expect to leverage Node `Stream`s in order to avoid the necessity of buffering a bunch of files in memory. Unfortunately, the combination of issues in CouchDB and `request` prevents this.
    
    1) CouchDB has [a nasty bug](https://issues.apache.org/jira/browse/COUCHDB-2295) which prevents from using `Transfer-Encoding: chunked` along with `Content-Type: multipart/related`. It won't be fixed until `1.7`, and its status in `2.x` branch is unknown.
    2) `request` uses exactly the `Transfer-Encoding: chunked` to upload data from `Stream`s. Uh-oh.
    3) `request` could be told explicitly not to use `chunked` encoding - but then you can't give it any `Stream`s! See [docs for a `multipart` option in request(options, callback)](https://github.com/request/request#requestoptions-callback). Bummer.
    
    Technically, it should be possible to stream a bunch of attachments, in case where one knows the length of the stream beforehand (which is not a problem when you upload files from a disk). I attempted to add the support for this case in dscape/nano#300, but failed miserably because `request` rightfully thinks it's smarter than me.

----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---