I start with a document located at
localhost:5984/categories/Jan
with the following data:
{
"_id": "Jan",
"_rev": "4-2c0b1c27daca6d2a3c375b0f879a8967",
"name": "Jan",
}
I want to upload a pdf to this document, so I give the following curl command:
curl -vX PUT 'http://localhost:5984/categories/Jan/example.pdf?rev=4-2c0b1c27daca6d2a3c375b0f879a8967' -d@example.pdf -H "ContentType: application/pdf"
And I get this response:
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5984 (#0)
> PUT /categories/Jan/example.pdf?rev=4-2c0b1c27daca6d2a3c375b0f879a8967 HTTP/1.1
> Host: localhost:5984
> User-Agent: curl/7.47.0
> Accept: */*
> ContentType: application/pdf
> Content-Length: 10944067
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< Server: MochiWeb/1.0 (Any of you quaids got a smint?)
< Date: Thu, 11 Jan 2018 07:48:21 GMT
< Connection: close
* We are completely uploaded and fine
< HTTP/1.1 201 Created
< X-CouchDB-Body-Time: 0
< X-Couch-Request-ID: d509f366b8
< Server: CouchDB/2.1.1 (Erlang OTP/18)
< Location: http://localhost:5984/categories/Jan/example.pdf
< Date: Thu, 11 Jan 2018 07:48:23 GMT
< Content-Type: application/json
< Content-Length: 66
< Cache-Control: must-revalidate
<
{"ok":true,"id":"Jan","rev":"5-4ae0ca0bd54d63b9ac45e3e57785648d"}
This appears to me to be a successful upload. However, when I visit the url
localhost:5984/categories/Jan/example.pdf
, there are two problems:
- instead of opening in the browser, I'm asked to download the attachment
- when I download and open the attachment, it says the data can't be read.
This happens for other content-types besides pdfs (I've also tried w/ a png). Can anyone let me know what might be going wrong? Thanks.