jo commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-787519647


   I also ran into this regression in multipart attachment support when I tried 
to update nano in [couchdb-push](https://github.com/jo/couchdb-push). I'll use 
8.2 for the time being. But I really like the switch to axios and the minimal 
dependency footprint, this is really awesome work!
   
   I tried to debug the issue, but without much luck.
   
   There is a test for this, but it [shows a false 
positive](https://travis-ci.com/github/apache/couchdb-nano/jobs/486143511#L227).
 The request is [nocked 
here](https://github.com/apache/couchdb-nano/blob/main/test/multipart.insert.test.js#L56-L58)
 but doesn't test the attachment request body sent.
   
   I tried running the testsuite locally with `NOCK_OFF=true` but that seems 
not supported anymore? I see there is a [hardcoded couchdb 
url](https://github.com/apache/couchdb-nano/blob/main/test/multipart.insert.test.js#L14),
 so it won't work against a Couch v3 (admin party has been removed from couch > 
2). So I tried running it against  couch v2 and also couch v1.7.2, but the 
testsuite fails with a lot of tests and I aborted it.
   
   Next thing I tried was running the attachment test alone, with
   
   ```sh
   NOCK_OFF=true npx jest --env node test/multipart.insert.test.js
   ```
   and it throws `Database does not exist.` Looks like there's some setup code 
gone.
   
   Looking at the code, the multipart data is [added to the 
request](https://github.com/apache/couchdb-nano/blob/main/lib/nano.js#L282), 
which is later [passed to 
axios](https://github.com/apache/couchdb-nano/blob/main/lib/nano.js#L412). But 
there seems [no handling of multipart data in 
axios](https://github.com/axios/axios/search?q=multipart).
   
   So from what I understand is needed is to manually construct the multipart 
body. In the browser, this can be done via `FormData` and in node possibly with 
the [form-data](https://www.npmjs.com/package/form-data) package.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to