我目前正在使用CouchDB并测试“独立附件”功能,该功能在
this page
.
我尝试使用curl的--data-urlencode特性来发送创建请求,这只起到一半作用。我可以创建附件并检索它,但是内容类型字段是错误的,因此图像无法正确显示。
更准确地说,CouchDB通过使用发布的内容类型返回附件来工作。我的问题是curl没有发送正确的代码。详细情况如下:
curl -vX PUT http://localhost:5984/dafttest/666/attachment --data-urlencode image/jpeg@xi_on_beach.jpg
* About to connect() to localhost port 5984 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5984 (#0)
> PUT /dafttest/666/attachment HTTP/1.1
> User-Agent: curl/7.19.4 (x86_64-pc-linux-gnu) libcurl/7.19.4 OpenSSL/0.9.8k zlib/1.2.3
> Host: localhost:5984
> Accept: */*
> Content-Length: 495389
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
所以这个问题的简短版本是:如何让curl发送正确的内容类型?
编辑:
我承认我的另一个错误是使用--data urlencode,当要使它工作时,我需要使用--data binary@filename和dale建议的-h选项。