【发布时间】:2016-06-23 11:12:00
【问题描述】:
使用本指南学习 Couchdb:http://guide.couchdb.org/editions/1/en/tour.html
我已经开始上传文件了。我可以使用浏览器但不能从命令行执行此操作,不幸的是这是我第一次使用 JSON,所以知道我做错了什么非常棘手,有人可以告诉我我可能做错了什么。
所以我检查并仔细检查了“-id”和“-rev”,它们与我正在使用的文档都是正确的,因为我可以成功添加其他带有文本的字段。 我在图像文件所在的同一目录中,我创建了一个小 jpg 图像并将其命名为 thing.jpg
这是我尝试使用的代码:
curl -vX PUT http://127.0.0.1:5984/albums/b8afcee69b7f2d7267bda14dc2002ba3/ thing.jpg?rev=1-08e6f33452dc44b0aa0df15c2cda1a98 --data-binary @thing.jpg -H "Content-Type: image/jpg
下面是回复:
> PUT /albums/b8afcee69b7f2d7267bda14dc2002ba3/ HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:5984
> Accept: */*
> Content-Type: image/jpg
> Content-Length: 39844
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 400 Bad Request
< Server: CouchDB/1.4.0 (Erlang OTP/17)
< Date: Wed, 22 Jun 2016 09:46:05 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 48
< Cache-Control: must-revalidate
* HTTP error before end of send, stop sending
<
* Closing connection 0
* Rebuilt URL to: thing.jpg/?rev=1-08e6f33452dc44b0aa0df15c2cda1a98
* Hostname was NOT found in DNS cache
* Could not resolve host: thing.jpg
* Closing connection 1
curl: (6) Could not resolve host: thing.jpg
除此之外,语法看起来与教程相同,但我收到此错误,如前所述,我可以添加其他字段但不能通过 curl 命令上传。我尝试使用不同的文档通过浏览器 UI 上传图像,结果很好。
请指出正确的方向来纠正这个问题,或者至少让我知道我做错了什么,以便我可以更好地研究这个问题。
亲切的问候
【问题讨论】: