本地主机:5984 /分类/月
以下数据:
{ "_ID": "Jan","_rev": "4-2c0b1c27daca6d2a3c375b0f879a8967","name": "Jan",}
我想将pdf上传到此文档,因此我提供以下curl命令:
curl -vX PUT 'http://localhost:5984/categorIEs/Jan/example.pdf?rev=4-2c0b1c27daca6d2a3c375b0f879a8967' -d@example.pdf -H "ContentType: application/pdf"
我得到了这样的答复:
* 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"}
在我看来,这是一个成功的上传.但是,当我访问网址时
localhost:5984 / categorIEs / Jan / example.pdf,有两个问题:
>而不是在浏览器中打开,我被要求下载附件
>当我下载并打开附件时,它表示无法读取数据.
除了pdf之外,其他内容类型也会发生这种情况(我也尝试过使用png).谁能让我知道可能会出错?谢谢.
解决方法 问题似乎是您在附件创建期间指定的ContentType标头.正确的标题名称是Content-Type
curl命令应该是:
curl -vX PUT 'http://localhost:5984/categorIEs/Jan/example.pdf?rev=4-2c0b1c27daca6d2a3c375b0f879a8967' -d@example.pdf -H "Content-Type: application/pdf"总结
以上是内存溢出为你收集整理的curl – 无法打开CouchDB附件全部内容,希望文章能够帮你解决curl – 无法打开CouchDB附件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)