You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "Yves S. Garret" <yo...@gmail.com> on 2013/07/16 17:05:59 UTC

Can't upload a pic to CouchDB.

I'm going through this book and I'm in this section:
http://guide.couchdb.org/editions/1/en/api.html#attachments

I try this in the command line and this is the error that I get:
% curl -vX PUT
http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
@artwork.jpg -H "Content-Type: image/jpg"
zsh: no matches found:
http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689

Am I making a stupid copy/paste mistake that's not immediately
obvious?  There is an artwork.jpg in the directory that I'm working
in.

Re: Can't upload a pic to CouchDB.

Posted by Andrew Melo <an...@gmail.com>.
On Tue, Jul 16, 2013 at 10:05 AM, Yves S. Garret <yoursurrogategod@gmail.com
> wrote:

> I'm going through this book and I'm in this section:
> http://guide.couchdb.org/editions/1/en/api.html#attachments
>
> I try this in the command line and this is the error that I get:
> % curl -vX PUT
>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> @artwork.jpg -H "Content-Type: image/jpg"
> zsh: no matches found:
>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>
> Am I making a stupid copy/paste mistake that's not immediately
> obvious?  There is an artwork.jpg in the directory that I'm working
> in.
>

It looks like zsh doesn't like the characters in the url (probably the ?).
Try quoting it. I'm unfamiliar with zsh, but I think double-quotes around
it would work there.


cheers,
Andrew



-- 
--
Andrew Melo

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 11:09 AM, Robert Newson <rn...@apache.org> wrote:

> Yes, you are ignoring your shell's helpful message :)
>
> try putting quotes around your url.
>
> B.
>
>
> On 16 July 2013 16:05, Yves S. Garret <yo...@gmail.com> wrote:
> > I'm going through this book and I'm in this section:
> > http://guide.couchdb.org/editions/1/en/api.html#attachments
> >
> > I try this in the command line and this is the error that I get:
> > % curl -vX PUT
> >
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> > @artwork.jpg -H "Content-Type: image/jpg"
> > zsh: no matches found:
> >
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
> >
> > Am I making a stupid copy/paste mistake that's not immediately
> > obvious?  There is an artwork.jpg in the directory that I'm working
> > in.
>

I have, no luck:

% curl -vX PUT "
http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689"
--data-binary @artwork.jpg -H "Content-Type: image/jpg"
* About to connect() to 127.0.0.1 port 5984 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7ff054008c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7ff054008c00) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> PUT /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
HTTP/1.1
> User-Agent: curl/7.31.0
> Host: 127.0.0.1:5984
> Accept: */*
> Content-Type: image/jpg
> Content-Length: 15138
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 409 Conflict
* Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
< Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
< Date: Tue, 16 Jul 2013 15:37:47 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 58
< Cache-Control: must-revalidate
* HTTP error before end of send, stop sending
<
{"error":"conflict","reason":"Document update conflict."}
* Closing connection 0

Re: Can't upload a pic to CouchDB.

Posted by Robert Newson <rn...@apache.org>.
Yes, you are ignoring your shell's helpful message :)

try putting quotes around your url.

B.


On 16 July 2013 16:05, Yves S. Garret <yo...@gmail.com> wrote:
> I'm going through this book and I'm in this section:
> http://guide.couchdb.org/editions/1/en/api.html#attachments
>
> I try this in the command line and this is the error that I get:
> % curl -vX PUT
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> @artwork.jpg -H "Content-Type: image/jpg"
> zsh: no matches found:
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>
> Am I making a stupid copy/paste mistake that's not immediately
> obvious?  There is an artwork.jpg in the directory that I'm working
> in.

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 4:19 PM, Robert Newson <rn...@apache.org> wrote:

> I think the error message is very descriptive and tells you exactly what
> to do.
>
> B.
>
>
> On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com> wrote:
> > On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
> > <yo...@gmail.com>wrote:
> >
> >> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
> >> yoursurrogategod@gmail.com> wrote:
> >>
> >>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rnewson@apache.org
> >wrote:
> >>>
> >>>> You need to pass the current rev, which clearly doesn't match the one
> >>>> you tried and got the 409 conflict telling you it was wrong for.
> >>>>
> >>>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com>
> >>>> wrote:
> >>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
> >>>> > <yo...@gmail.com> wrote:
> >>>> >>
> >>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
> >>>> wrote:
> >>>> >>>
> >>>> >>> Do you have a space before "--data-binary" when you run the
> command?
> >>>> >>>
> >>>> >>>
> >>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
> >>>> >>> <yoursurrogategod@gmail.com
> >>>> >>> > wrote:
> >>>> >>>
> >>>> >>> > I'm going through this book and I'm in this section:
> >>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
> >>>> >>> >
> >>>> >>> > I try this in the command line and this is the error that I get:
> >>>> >>> > % curl -vX PUT
> >>>> >>> >
> >>>> >>> >
> >>>> >>> >
> >>>>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> >>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
> >>>> >>> > zsh: no matches found:
> >>>> >>> >
> >>>> >>> >
> >>>> >>> >
> >>>>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
> >>>> >>> >
> >>>> >>> > Am I making a stupid copy/paste mistake that's not immediately
> >>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm
> working
> >>>> >>> > in.
> >>>> >>> >
> >>>> >>
> >>>> >>
> >>>> >> Yes.
> >>>> >
> >>>> >
> >>>> > This is what's in the database at the moment (if it helps):
> >>>> >
> >>>> > {
> >>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
> >>>> >    "title": "There is Nothing Left to Lose",
> >>>> >    "artist": "Foo Fighters"
> >>>> > }
> >>>> >
> >>>> >
> >>>> > And I've attached the file with the actual DB.
> >>>>
> >>>
> >>> Gotcha.  It worked.  Thanks.
> >>>
> >>
> >> One more question, would it be possible to include multiple binary
> >> uploaded files?
> >>
> >> This is what I tried and the results that I got:
> >>
> >> % curl -vX PUT "
> >>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> "
> >> --data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
> >> image/jpg"
> >> * About to connect() to 127.0.0.1 port 5984 (#0)
> >> *   Trying 127.0.0.1...
> >> * Adding handle: conn: 0x7fe5c4007c00
> >> * Adding handle: send: 0
> >> * Adding handle: recv: 0
> >> * Curl_addHandleToPipeline: length: 1
> >> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
> >> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> >> > PUT
> >>
> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> >> HTTP/1.1
> >> > User-Agent: curl/7.31.0
> >> > Host: 127.0.0.1:5984
> >> > Accept: */*
> >> > Content-Type: image/jpg
> >> > Content-Length: 161673
> >> > Expect: 100-continue
> >> >
> >> < HTTP/1.1 100 Continue
> >> < HTTP/1.1 409 Conflict
> >> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> >> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> >> < Date: Tue, 16 Jul 2013 19:19:45 GMT
> >> < Content-Type: text/plain; charset=utf-8
> >> < Content-Length: 58
> >> < Cache-Control: must-revalidate
> >> * HTTP error before end of send, stop sending
> >> <
> >> {"error":"conflict","reason":"Document update conflict."}
> >> * Closing connection 0
> >>
> >> This is the current record:
> >>
> >> {
> >>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
> >>    "title": "There is Nothing Left to Lose",
> >>    "artist": "Foo Fighters",
> >>    "_attachments": {
> >>        "artwork.jpg": {
> >>            "content_type": "image/jpg",
> >>            "revpos": 2,
> >>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
> >>            "length": 15138,
> >>            "stub": true
> >>        }
> >>    }
> >> }
> >>
> >
> > This is off-topic, but when I tried to setup a replication DB, this is
> the
> > error that I got:
> >
> > % curl -X PUT http://127.0.0.1:5984/albums-replica
> > {"ok":true}
> > % curl -vX POST http://127.0.0.1:5984/_replicate -d '{"source":"albums",
> > "target":"albums-replica"}'
> > * About to connect() to 127.0.0.1 port 5984 (#0)
> > *   Trying 127.0.0.1...
> > * Adding handle: conn: 0x7fb592808c00
> > * Adding handle: send: 0
> > * Adding handle: recv: 0
> > * Curl_addHandleToPipeline: length: 1
> > * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
> > * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> >> POST /_replicate HTTP/1.1
> >> User-Agent: curl/7.31.0
> >> Host: 127.0.0.1:5984
> >> Accept: */*
> >> Content-Length: 46
> >> Content-Type: application/x-www-form-urlencoded
> >>
> > * upload completely sent off: 46 out of 46 bytes
> > < HTTP/1.1 415 Unsupported Media Type
> > * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> > < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> > < Date: Tue, 16 Jul 2013 19:23:34 GMT
> > < Content-Type: text/plain; charset=utf-8
> > < Content-Length: 78
> > < Cache-Control: must-revalidate
> > <
> > {"error":"bad_content_type","reason":"Content-Type must be
> > application/json"}
> >
> > Thoughts?
> >
> > But also, is there an index of general CouchDB errors that I can refer to
> > and find
> > out the general causes behind those errors?
>

I disagree.  After doing some more googling, this is what I've found:
https://github.com/oreilly/couchdb-guide/issues/427

So, now, this will work:
% curl -vX POST http://127.0.0.1:5984/_replicate -d '{"source" : "albums",
"target" : "http://127.0.0.1:5984/albums-replica"}' -H"Content-Type:
application/json"
* About to connect() to 127.0.0.1 port 5984 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7faa21008c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7faa21008c00) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> POST /_replicate HTTP/1.1
> User-Agent: curl/7.31.0
> Host: 127.0.0.1:5984
> Accept: */*
> Content-Type: application/json
> Content-Length: 72
>
* upload completely sent off: 72 out of 72 bytes
< HTTP/1.1 200 OK
* Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
< Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
< Date: Tue, 16 Jul 2013 20:22:22 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 402
< Cache-Control: must-revalidate
<
{"ok":true,"session_id":"a28ec841b2f720d281d659b7ac7b3049","source_last_seq":3,"replication_id_version":3,"history":[{"session_id":"a28ec841b2f720d281d659b7ac7b3049","start_time":"Tue,
16 Jul 2013 20:22:22 GMT","end_time":"Tue, 16 Jul 2013 20:22:22
GMT","start_last_seq":0,"end_last_seq":3,"recorded_seq":3,"missing_checked":1,"missing_found":1,"docs_read":1,"docs_written":1,"doc_write_failures":0}]}
* Connection #0 to host 127.0.0.1 left intact

Honestly, as a n00b to CouchDB, this wasn't terribly obvious.  And the
online
book would need to be updated.

Re: Can't upload a pic to CouchDB.

Posted by Robert Newson <rn...@apache.org>.
Hm, ok. Noted. thanks.

On 16 July 2013 21:35, Yves S. Garret <yo...@gmail.com> wrote:
> On Tue, Jul 16, 2013 at 4:32 PM, Robert Newson <rn...@apache.org> wrote:
>
>> You really think that "Content-Type must be application/json" isn't
>> telling you what you need to do (namely, set the content-type to
>> application/json)? :)
>>
>> B.
>>
>>
>> On 16 July 2013 21:25, Yves S. Garret <yo...@gmail.com> wrote:
>> > On Tue, Jul 16, 2013 at 4:20 PM, Robert Newson <rn...@apache.org>
>> wrote:
>> >
>> >> You can upload a document and all its attachments in one PUT request
>> >> if you use multipart/related, yes. Check the test suite for a working
>> >> example.
>> >>
>> >> B.
>> >>
>> >>
>> >> On 16 July 2013 21:19, Robert Newson <rn...@apache.org> wrote:
>> >> > I think the error message is very descriptive and tells you exactly
>> what
>> >> to do.
>> >> >
>> >> > B.
>> >> >
>> >> >
>> >> > On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com>
>> >> wrote:
>> >> >> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
>> >> >> <yo...@gmail.com>wrote:
>> >> >>
>> >> >>> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
>> >> >>> yoursurrogategod@gmail.com> wrote:
>> >> >>>
>> >> >>>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rnewson@apache.org
>> >> >wrote:
>> >> >>>>
>> >> >>>>> You need to pass the current rev, which clearly doesn't match the
>> one
>> >> >>>>> you tried and got the 409 conflict telling you it was wrong for.
>> >> >>>>>
>> >> >>>>> On 16 July 2013 18:07, Yves S. Garret <yoursurrogategod@gmail.com
>> >
>> >> >>>>> wrote:
>> >> >>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
>> >> >>>>> > <yo...@gmail.com> wrote:
>> >> >>>>> >>
>> >> >>>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <
>> tisdall@gmail.com>
>> >> >>>>> wrote:
>> >> >>>>> >>>
>> >> >>>>> >>> Do you have a space before "--data-binary" when you run the
>> >> command?
>> >> >>>>> >>>
>> >> >>>>> >>>
>> >> >>>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>> >> >>>>> >>> <yoursurrogategod@gmail.com
>> >> >>>>> >>> > wrote:
>> >> >>>>> >>>
>> >> >>>>> >>> > I'm going through this book and I'm in this section:
>> >> >>>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>> >> >>>>> >>> >
>> >> >>>>> >>> > I try this in the command line and this is the error that I
>> >> get:
>> >> >>>>> >>> > % curl -vX PUT
>> >> >>>>> >>> >
>> >> >>>>> >>> >
>> >> >>>>> >>> >
>> >> >>>>>
>> >>
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>> >> >>>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
>> >> >>>>> >>> > zsh: no matches found:
>> >> >>>>> >>> >
>> >> >>>>> >>> >
>> >> >>>>> >>> >
>> >> >>>>>
>> >>
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>> >> >>>>> >>> >
>> >> >>>>> >>> > Am I making a stupid copy/paste mistake that's not
>> immediately
>> >> >>>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm
>> >> working
>> >> >>>>> >>> > in.
>> >> >>>>> >>> >
>> >> >>>>> >>
>> >> >>>>> >>
>> >> >>>>> >> Yes.
>> >> >>>>> >
>> >> >>>>> >
>> >> >>>>> > This is what's in the database at the moment (if it helps):
>> >> >>>>> >
>> >> >>>>> > {
>> >> >>>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>> >> >>>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>> >> >>>>> >    "title": "There is Nothing Left to Lose",
>> >> >>>>> >    "artist": "Foo Fighters"
>> >> >>>>> > }
>> >> >>>>> >
>> >> >>>>> >
>> >> >>>>> > And I've attached the file with the actual DB.
>> >> >>>>>
>> >> >>>>
>> >> >>>> Gotcha.  It worked.  Thanks.
>> >> >>>>
>> >> >>>
>> >> >>> One more question, would it be possible to include multiple binary
>> >> >>> uploaded files?
>> >> >>>
>> >> >>> This is what I tried and the results that I got:
>> >> >>>
>> >> >>> % curl -vX PUT "
>> >> >>>
>> >>
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
>> >> "
>> >> >>> --data-binary @artwork.jpg --data-binary @sample2.jpg -H
>> "Content-Type:
>> >> >>> image/jpg"
>> >> >>> * About to connect() to 127.0.0.1 port 5984 (#0)
>> >> >>> *   Trying 127.0.0.1...
>> >> >>> * Adding handle: conn: 0x7fe5c4007c00
>> >> >>> * Adding handle: send: 0
>> >> >>> * Adding handle: recv: 0
>> >> >>> * Curl_addHandleToPipeline: length: 1
>> >> >>> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
>> >> >>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> >> >>> > PUT
>> >> >>>
>> >>
>> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
>> >> >>> HTTP/1.1
>> >> >>> > User-Agent: curl/7.31.0
>> >> >>> > Host: 127.0.0.1:5984
>> >> >>> > Accept: */*
>> >> >>> > Content-Type: image/jpg
>> >> >>> > Content-Length: 161673
>> >> >>> > Expect: 100-continue
>> >> >>> >
>> >> >>> < HTTP/1.1 100 Continue
>> >> >>> < HTTP/1.1 409 Conflict
>> >> >>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>> >> >>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>> >> >>> < Date: Tue, 16 Jul 2013 19:19:45 GMT
>> >> >>> < Content-Type: text/plain; charset=utf-8
>> >> >>> < Content-Length: 58
>> >> >>> < Cache-Control: must-revalidate
>> >> >>> * HTTP error before end of send, stop sending
>> >> >>> <
>> >> >>> {"error":"conflict","reason":"Document update conflict."}
>> >> >>> * Closing connection 0
>> >> >>>
>> >> >>> This is the current record:
>> >> >>>
>> >> >>> {
>> >> >>>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>> >> >>>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
>> >> >>>    "title": "There is Nothing Left to Lose",
>> >> >>>    "artist": "Foo Fighters",
>> >> >>>    "_attachments": {
>> >> >>>        "artwork.jpg": {
>> >> >>>            "content_type": "image/jpg",
>> >> >>>            "revpos": 2,
>> >> >>>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
>> >> >>>            "length": 15138,
>> >> >>>            "stub": true
>> >> >>>        }
>> >> >>>    }
>> >> >>> }
>> >> >>>
>> >> >>
>> >> >> This is off-topic, but when I tried to setup a replication DB, this
>> is
>> >> the
>> >> >> error that I got:
>> >> >>
>> >> >> % curl -X PUT http://127.0.0.1:5984/albums-replica
>> >> >> {"ok":true}
>> >> >> % curl -vX POST http://127.0.0.1:5984/_replicate -d
>> >> '{"source":"albums",
>> >> >> "target":"albums-replica"}'
>> >> >> * About to connect() to 127.0.0.1 port 5984 (#0)
>> >> >> *   Trying 127.0.0.1...
>> >> >> * Adding handle: conn: 0x7fb592808c00
>> >> >> * Adding handle: send: 0
>> >> >> * Adding handle: recv: 0
>> >> >> * Curl_addHandleToPipeline: length: 1
>> >> >> * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
>> >> >> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> >> >>> POST /_replicate HTTP/1.1
>> >> >>> User-Agent: curl/7.31.0
>> >> >>> Host: 127.0.0.1:5984
>> >> >>> Accept: */*
>> >> >>> Content-Length: 46
>> >> >>> Content-Type: application/x-www-form-urlencoded
>> >> >>>
>> >> >> * upload completely sent off: 46 out of 46 bytes
>> >> >> < HTTP/1.1 415 Unsupported Media Type
>> >> >> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>> >> >> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>> >> >> < Date: Tue, 16 Jul 2013 19:23:34 GMT
>> >> >> < Content-Type: text/plain; charset=utf-8
>> >> >> < Content-Length: 78
>> >> >> < Cache-Control: must-revalidate
>> >> >> <
>> >> >> {"error":"bad_content_type","reason":"Content-Type must be
>> >> >> application/json"}
>> >> >>
>> >> >> Thoughts?
>> >> >>
>> >> >> But also, is there an index of general CouchDB errors that I can
>> refer
>> >> to
>> >> >> and find
>> >> >> out the general causes behind those errors?
>> >>
>> >
>> > Gotcha, will investigate further.
>>
>
> *shrug* I installed CouchDB last Saturday and started reading this book on
> Sunday.  Honestly, it just doesn't jump out enough at you.  And yes, this is
> my first time playing with CouchDB.
>
> It reminds me of the times that I was working with C++ for the very first
> time and all the fun associated with the intricacies of that language :) .

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 4:32 PM, Robert Newson <rn...@apache.org> wrote:

> You really think that "Content-Type must be application/json" isn't
> telling you what you need to do (namely, set the content-type to
> application/json)? :)
>
> B.
>
>
> On 16 July 2013 21:25, Yves S. Garret <yo...@gmail.com> wrote:
> > On Tue, Jul 16, 2013 at 4:20 PM, Robert Newson <rn...@apache.org>
> wrote:
> >
> >> You can upload a document and all its attachments in one PUT request
> >> if you use multipart/related, yes. Check the test suite for a working
> >> example.
> >>
> >> B.
> >>
> >>
> >> On 16 July 2013 21:19, Robert Newson <rn...@apache.org> wrote:
> >> > I think the error message is very descriptive and tells you exactly
> what
> >> to do.
> >> >
> >> > B.
> >> >
> >> >
> >> > On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com>
> >> wrote:
> >> >> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
> >> >> <yo...@gmail.com>wrote:
> >> >>
> >> >>> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
> >> >>> yoursurrogategod@gmail.com> wrote:
> >> >>>
> >> >>>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rnewson@apache.org
> >> >wrote:
> >> >>>>
> >> >>>>> You need to pass the current rev, which clearly doesn't match the
> one
> >> >>>>> you tried and got the 409 conflict telling you it was wrong for.
> >> >>>>>
> >> >>>>> On 16 July 2013 18:07, Yves S. Garret <yoursurrogategod@gmail.com
> >
> >> >>>>> wrote:
> >> >>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
> >> >>>>> > <yo...@gmail.com> wrote:
> >> >>>>> >>
> >> >>>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <
> tisdall@gmail.com>
> >> >>>>> wrote:
> >> >>>>> >>>
> >> >>>>> >>> Do you have a space before "--data-binary" when you run the
> >> command?
> >> >>>>> >>>
> >> >>>>> >>>
> >> >>>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
> >> >>>>> >>> <yoursurrogategod@gmail.com
> >> >>>>> >>> > wrote:
> >> >>>>> >>>
> >> >>>>> >>> > I'm going through this book and I'm in this section:
> >> >>>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
> >> >>>>> >>> >
> >> >>>>> >>> > I try this in the command line and this is the error that I
> >> get:
> >> >>>>> >>> > % curl -vX PUT
> >> >>>>> >>> >
> >> >>>>> >>> >
> >> >>>>> >>> >
> >> >>>>>
> >>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> >> >>>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
> >> >>>>> >>> > zsh: no matches found:
> >> >>>>> >>> >
> >> >>>>> >>> >
> >> >>>>> >>> >
> >> >>>>>
> >>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
> >> >>>>> >>> >
> >> >>>>> >>> > Am I making a stupid copy/paste mistake that's not
> immediately
> >> >>>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm
> >> working
> >> >>>>> >>> > in.
> >> >>>>> >>> >
> >> >>>>> >>
> >> >>>>> >>
> >> >>>>> >> Yes.
> >> >>>>> >
> >> >>>>> >
> >> >>>>> > This is what's in the database at the moment (if it helps):
> >> >>>>> >
> >> >>>>> > {
> >> >>>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >> >>>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
> >> >>>>> >    "title": "There is Nothing Left to Lose",
> >> >>>>> >    "artist": "Foo Fighters"
> >> >>>>> > }
> >> >>>>> >
> >> >>>>> >
> >> >>>>> > And I've attached the file with the actual DB.
> >> >>>>>
> >> >>>>
> >> >>>> Gotcha.  It worked.  Thanks.
> >> >>>>
> >> >>>
> >> >>> One more question, would it be possible to include multiple binary
> >> >>> uploaded files?
> >> >>>
> >> >>> This is what I tried and the results that I got:
> >> >>>
> >> >>> % curl -vX PUT "
> >> >>>
> >>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> >> "
> >> >>> --data-binary @artwork.jpg --data-binary @sample2.jpg -H
> "Content-Type:
> >> >>> image/jpg"
> >> >>> * About to connect() to 127.0.0.1 port 5984 (#0)
> >> >>> *   Trying 127.0.0.1...
> >> >>> * Adding handle: conn: 0x7fe5c4007c00
> >> >>> * Adding handle: send: 0
> >> >>> * Adding handle: recv: 0
> >> >>> * Curl_addHandleToPipeline: length: 1
> >> >>> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
> >> >>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> >> >>> > PUT
> >> >>>
> >>
> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> >> >>> HTTP/1.1
> >> >>> > User-Agent: curl/7.31.0
> >> >>> > Host: 127.0.0.1:5984
> >> >>> > Accept: */*
> >> >>> > Content-Type: image/jpg
> >> >>> > Content-Length: 161673
> >> >>> > Expect: 100-continue
> >> >>> >
> >> >>> < HTTP/1.1 100 Continue
> >> >>> < HTTP/1.1 409 Conflict
> >> >>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> >> >>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> >> >>> < Date: Tue, 16 Jul 2013 19:19:45 GMT
> >> >>> < Content-Type: text/plain; charset=utf-8
> >> >>> < Content-Length: 58
> >> >>> < Cache-Control: must-revalidate
> >> >>> * HTTP error before end of send, stop sending
> >> >>> <
> >> >>> {"error":"conflict","reason":"Document update conflict."}
> >> >>> * Closing connection 0
> >> >>>
> >> >>> This is the current record:
> >> >>>
> >> >>> {
> >> >>>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >> >>>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
> >> >>>    "title": "There is Nothing Left to Lose",
> >> >>>    "artist": "Foo Fighters",
> >> >>>    "_attachments": {
> >> >>>        "artwork.jpg": {
> >> >>>            "content_type": "image/jpg",
> >> >>>            "revpos": 2,
> >> >>>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
> >> >>>            "length": 15138,
> >> >>>            "stub": true
> >> >>>        }
> >> >>>    }
> >> >>> }
> >> >>>
> >> >>
> >> >> This is off-topic, but when I tried to setup a replication DB, this
> is
> >> the
> >> >> error that I got:
> >> >>
> >> >> % curl -X PUT http://127.0.0.1:5984/albums-replica
> >> >> {"ok":true}
> >> >> % curl -vX POST http://127.0.0.1:5984/_replicate -d
> >> '{"source":"albums",
> >> >> "target":"albums-replica"}'
> >> >> * About to connect() to 127.0.0.1 port 5984 (#0)
> >> >> *   Trying 127.0.0.1...
> >> >> * Adding handle: conn: 0x7fb592808c00
> >> >> * Adding handle: send: 0
> >> >> * Adding handle: recv: 0
> >> >> * Curl_addHandleToPipeline: length: 1
> >> >> * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
> >> >> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> >> >>> POST /_replicate HTTP/1.1
> >> >>> User-Agent: curl/7.31.0
> >> >>> Host: 127.0.0.1:5984
> >> >>> Accept: */*
> >> >>> Content-Length: 46
> >> >>> Content-Type: application/x-www-form-urlencoded
> >> >>>
> >> >> * upload completely sent off: 46 out of 46 bytes
> >> >> < HTTP/1.1 415 Unsupported Media Type
> >> >> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> >> >> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> >> >> < Date: Tue, 16 Jul 2013 19:23:34 GMT
> >> >> < Content-Type: text/plain; charset=utf-8
> >> >> < Content-Length: 78
> >> >> < Cache-Control: must-revalidate
> >> >> <
> >> >> {"error":"bad_content_type","reason":"Content-Type must be
> >> >> application/json"}
> >> >>
> >> >> Thoughts?
> >> >>
> >> >> But also, is there an index of general CouchDB errors that I can
> refer
> >> to
> >> >> and find
> >> >> out the general causes behind those errors?
> >>
> >
> > Gotcha, will investigate further.
>

*shrug* I installed CouchDB last Saturday and started reading this book on
Sunday.  Honestly, it just doesn't jump out enough at you.  And yes, this is
my first time playing with CouchDB.

It reminds me of the times that I was working with C++ for the very first
time and all the fun associated with the intricacies of that language :) .

Re: Can't upload a pic to CouchDB.

Posted by Robert Newson <rn...@apache.org>.
You really think that "Content-Type must be application/json" isn't
telling you what you need to do (namely, set the content-type to
application/json)? :)

B.


On 16 July 2013 21:25, Yves S. Garret <yo...@gmail.com> wrote:
> On Tue, Jul 16, 2013 at 4:20 PM, Robert Newson <rn...@apache.org> wrote:
>
>> You can upload a document and all its attachments in one PUT request
>> if you use multipart/related, yes. Check the test suite for a working
>> example.
>>
>> B.
>>
>>
>> On 16 July 2013 21:19, Robert Newson <rn...@apache.org> wrote:
>> > I think the error message is very descriptive and tells you exactly what
>> to do.
>> >
>> > B.
>> >
>> >
>> > On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com>
>> wrote:
>> >> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
>> >> <yo...@gmail.com>wrote:
>> >>
>> >>> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
>> >>> yoursurrogategod@gmail.com> wrote:
>> >>>
>> >>>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rnewson@apache.org
>> >wrote:
>> >>>>
>> >>>>> You need to pass the current rev, which clearly doesn't match the one
>> >>>>> you tried and got the 409 conflict telling you it was wrong for.
>> >>>>>
>> >>>>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com>
>> >>>>> wrote:
>> >>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
>> >>>>> > <yo...@gmail.com> wrote:
>> >>>>> >>
>> >>>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
>> >>>>> wrote:
>> >>>>> >>>
>> >>>>> >>> Do you have a space before "--data-binary" when you run the
>> command?
>> >>>>> >>>
>> >>>>> >>>
>> >>>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>> >>>>> >>> <yoursurrogategod@gmail.com
>> >>>>> >>> > wrote:
>> >>>>> >>>
>> >>>>> >>> > I'm going through this book and I'm in this section:
>> >>>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>> >>>>> >>> >
>> >>>>> >>> > I try this in the command line and this is the error that I
>> get:
>> >>>>> >>> > % curl -vX PUT
>> >>>>> >>> >
>> >>>>> >>> >
>> >>>>> >>> >
>> >>>>>
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>> >>>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
>> >>>>> >>> > zsh: no matches found:
>> >>>>> >>> >
>> >>>>> >>> >
>> >>>>> >>> >
>> >>>>>
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>> >>>>> >>> >
>> >>>>> >>> > Am I making a stupid copy/paste mistake that's not immediately
>> >>>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm
>> working
>> >>>>> >>> > in.
>> >>>>> >>> >
>> >>>>> >>
>> >>>>> >>
>> >>>>> >> Yes.
>> >>>>> >
>> >>>>> >
>> >>>>> > This is what's in the database at the moment (if it helps):
>> >>>>> >
>> >>>>> > {
>> >>>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>> >>>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>> >>>>> >    "title": "There is Nothing Left to Lose",
>> >>>>> >    "artist": "Foo Fighters"
>> >>>>> > }
>> >>>>> >
>> >>>>> >
>> >>>>> > And I've attached the file with the actual DB.
>> >>>>>
>> >>>>
>> >>>> Gotcha.  It worked.  Thanks.
>> >>>>
>> >>>
>> >>> One more question, would it be possible to include multiple binary
>> >>> uploaded files?
>> >>>
>> >>> This is what I tried and the results that I got:
>> >>>
>> >>> % curl -vX PUT "
>> >>>
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
>> "
>> >>> --data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
>> >>> image/jpg"
>> >>> * About to connect() to 127.0.0.1 port 5984 (#0)
>> >>> *   Trying 127.0.0.1...
>> >>> * Adding handle: conn: 0x7fe5c4007c00
>> >>> * Adding handle: send: 0
>> >>> * Adding handle: recv: 0
>> >>> * Curl_addHandleToPipeline: length: 1
>> >>> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
>> >>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> >>> > PUT
>> >>>
>> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
>> >>> HTTP/1.1
>> >>> > User-Agent: curl/7.31.0
>> >>> > Host: 127.0.0.1:5984
>> >>> > Accept: */*
>> >>> > Content-Type: image/jpg
>> >>> > Content-Length: 161673
>> >>> > Expect: 100-continue
>> >>> >
>> >>> < HTTP/1.1 100 Continue
>> >>> < HTTP/1.1 409 Conflict
>> >>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>> >>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>> >>> < Date: Tue, 16 Jul 2013 19:19:45 GMT
>> >>> < Content-Type: text/plain; charset=utf-8
>> >>> < Content-Length: 58
>> >>> < Cache-Control: must-revalidate
>> >>> * HTTP error before end of send, stop sending
>> >>> <
>> >>> {"error":"conflict","reason":"Document update conflict."}
>> >>> * Closing connection 0
>> >>>
>> >>> This is the current record:
>> >>>
>> >>> {
>> >>>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>> >>>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
>> >>>    "title": "There is Nothing Left to Lose",
>> >>>    "artist": "Foo Fighters",
>> >>>    "_attachments": {
>> >>>        "artwork.jpg": {
>> >>>            "content_type": "image/jpg",
>> >>>            "revpos": 2,
>> >>>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
>> >>>            "length": 15138,
>> >>>            "stub": true
>> >>>        }
>> >>>    }
>> >>> }
>> >>>
>> >>
>> >> This is off-topic, but when I tried to setup a replication DB, this is
>> the
>> >> error that I got:
>> >>
>> >> % curl -X PUT http://127.0.0.1:5984/albums-replica
>> >> {"ok":true}
>> >> % curl -vX POST http://127.0.0.1:5984/_replicate -d
>> '{"source":"albums",
>> >> "target":"albums-replica"}'
>> >> * About to connect() to 127.0.0.1 port 5984 (#0)
>> >> *   Trying 127.0.0.1...
>> >> * Adding handle: conn: 0x7fb592808c00
>> >> * Adding handle: send: 0
>> >> * Adding handle: recv: 0
>> >> * Curl_addHandleToPipeline: length: 1
>> >> * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
>> >> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> >>> POST /_replicate HTTP/1.1
>> >>> User-Agent: curl/7.31.0
>> >>> Host: 127.0.0.1:5984
>> >>> Accept: */*
>> >>> Content-Length: 46
>> >>> Content-Type: application/x-www-form-urlencoded
>> >>>
>> >> * upload completely sent off: 46 out of 46 bytes
>> >> < HTTP/1.1 415 Unsupported Media Type
>> >> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>> >> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>> >> < Date: Tue, 16 Jul 2013 19:23:34 GMT
>> >> < Content-Type: text/plain; charset=utf-8
>> >> < Content-Length: 78
>> >> < Cache-Control: must-revalidate
>> >> <
>> >> {"error":"bad_content_type","reason":"Content-Type must be
>> >> application/json"}
>> >>
>> >> Thoughts?
>> >>
>> >> But also, is there an index of general CouchDB errors that I can refer
>> to
>> >> and find
>> >> out the general causes behind those errors?
>>
>
> Gotcha, will investigate further.

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 4:20 PM, Robert Newson <rn...@apache.org> wrote:

> You can upload a document and all its attachments in one PUT request
> if you use multipart/related, yes. Check the test suite for a working
> example.
>
> B.
>
>
> On 16 July 2013 21:19, Robert Newson <rn...@apache.org> wrote:
> > I think the error message is very descriptive and tells you exactly what
> to do.
> >
> > B.
> >
> >
> > On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com>
> wrote:
> >> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
> >> <yo...@gmail.com>wrote:
> >>
> >>> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
> >>> yoursurrogategod@gmail.com> wrote:
> >>>
> >>>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rnewson@apache.org
> >wrote:
> >>>>
> >>>>> You need to pass the current rev, which clearly doesn't match the one
> >>>>> you tried and got the 409 conflict telling you it was wrong for.
> >>>>>
> >>>>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com>
> >>>>> wrote:
> >>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
> >>>>> > <yo...@gmail.com> wrote:
> >>>>> >>
> >>>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
> >>>>> wrote:
> >>>>> >>>
> >>>>> >>> Do you have a space before "--data-binary" when you run the
> command?
> >>>>> >>>
> >>>>> >>>
> >>>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
> >>>>> >>> <yoursurrogategod@gmail.com
> >>>>> >>> > wrote:
> >>>>> >>>
> >>>>> >>> > I'm going through this book and I'm in this section:
> >>>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
> >>>>> >>> >
> >>>>> >>> > I try this in the command line and this is the error that I
> get:
> >>>>> >>> > % curl -vX PUT
> >>>>> >>> >
> >>>>> >>> >
> >>>>> >>> >
> >>>>>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> >>>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
> >>>>> >>> > zsh: no matches found:
> >>>>> >>> >
> >>>>> >>> >
> >>>>> >>> >
> >>>>>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
> >>>>> >>> >
> >>>>> >>> > Am I making a stupid copy/paste mistake that's not immediately
> >>>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm
> working
> >>>>> >>> > in.
> >>>>> >>> >
> >>>>> >>
> >>>>> >>
> >>>>> >> Yes.
> >>>>> >
> >>>>> >
> >>>>> > This is what's in the database at the moment (if it helps):
> >>>>> >
> >>>>> > {
> >>>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >>>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
> >>>>> >    "title": "There is Nothing Left to Lose",
> >>>>> >    "artist": "Foo Fighters"
> >>>>> > }
> >>>>> >
> >>>>> >
> >>>>> > And I've attached the file with the actual DB.
> >>>>>
> >>>>
> >>>> Gotcha.  It worked.  Thanks.
> >>>>
> >>>
> >>> One more question, would it be possible to include multiple binary
> >>> uploaded files?
> >>>
> >>> This is what I tried and the results that I got:
> >>>
> >>> % curl -vX PUT "
> >>>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> "
> >>> --data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
> >>> image/jpg"
> >>> * About to connect() to 127.0.0.1 port 5984 (#0)
> >>> *   Trying 127.0.0.1...
> >>> * Adding handle: conn: 0x7fe5c4007c00
> >>> * Adding handle: send: 0
> >>> * Adding handle: recv: 0
> >>> * Curl_addHandleToPipeline: length: 1
> >>> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
> >>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> >>> > PUT
> >>>
> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> >>> HTTP/1.1
> >>> > User-Agent: curl/7.31.0
> >>> > Host: 127.0.0.1:5984
> >>> > Accept: */*
> >>> > Content-Type: image/jpg
> >>> > Content-Length: 161673
> >>> > Expect: 100-continue
> >>> >
> >>> < HTTP/1.1 100 Continue
> >>> < HTTP/1.1 409 Conflict
> >>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> >>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> >>> < Date: Tue, 16 Jul 2013 19:19:45 GMT
> >>> < Content-Type: text/plain; charset=utf-8
> >>> < Content-Length: 58
> >>> < Cache-Control: must-revalidate
> >>> * HTTP error before end of send, stop sending
> >>> <
> >>> {"error":"conflict","reason":"Document update conflict."}
> >>> * Closing connection 0
> >>>
> >>> This is the current record:
> >>>
> >>> {
> >>>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >>>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
> >>>    "title": "There is Nothing Left to Lose",
> >>>    "artist": "Foo Fighters",
> >>>    "_attachments": {
> >>>        "artwork.jpg": {
> >>>            "content_type": "image/jpg",
> >>>            "revpos": 2,
> >>>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
> >>>            "length": 15138,
> >>>            "stub": true
> >>>        }
> >>>    }
> >>> }
> >>>
> >>
> >> This is off-topic, but when I tried to setup a replication DB, this is
> the
> >> error that I got:
> >>
> >> % curl -X PUT http://127.0.0.1:5984/albums-replica
> >> {"ok":true}
> >> % curl -vX POST http://127.0.0.1:5984/_replicate -d
> '{"source":"albums",
> >> "target":"albums-replica"}'
> >> * About to connect() to 127.0.0.1 port 5984 (#0)
> >> *   Trying 127.0.0.1...
> >> * Adding handle: conn: 0x7fb592808c00
> >> * Adding handle: send: 0
> >> * Adding handle: recv: 0
> >> * Curl_addHandleToPipeline: length: 1
> >> * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
> >> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> >>> POST /_replicate HTTP/1.1
> >>> User-Agent: curl/7.31.0
> >>> Host: 127.0.0.1:5984
> >>> Accept: */*
> >>> Content-Length: 46
> >>> Content-Type: application/x-www-form-urlencoded
> >>>
> >> * upload completely sent off: 46 out of 46 bytes
> >> < HTTP/1.1 415 Unsupported Media Type
> >> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> >> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> >> < Date: Tue, 16 Jul 2013 19:23:34 GMT
> >> < Content-Type: text/plain; charset=utf-8
> >> < Content-Length: 78
> >> < Cache-Control: must-revalidate
> >> <
> >> {"error":"bad_content_type","reason":"Content-Type must be
> >> application/json"}
> >>
> >> Thoughts?
> >>
> >> But also, is there an index of general CouchDB errors that I can refer
> to
> >> and find
> >> out the general causes behind those errors?
>

Gotcha, will investigate further.

Re: Can't upload a pic to CouchDB.

Posted by Robert Newson <rn...@apache.org>.
You can upload a document and all its attachments in one PUT request
if you use multipart/related, yes. Check the test suite for a working
example.

B.


On 16 July 2013 21:19, Robert Newson <rn...@apache.org> wrote:
> I think the error message is very descriptive and tells you exactly what to do.
>
> B.
>
>
> On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com> wrote:
>> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
>> <yo...@gmail.com>wrote:
>>
>>> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
>>> yoursurrogategod@gmail.com> wrote:
>>>
>>>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rn...@apache.org>wrote:
>>>>
>>>>> You need to pass the current rev, which clearly doesn't match the one
>>>>> you tried and got the 409 conflict telling you it was wrong for.
>>>>>
>>>>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com>
>>>>> wrote:
>>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
>>>>> > <yo...@gmail.com> wrote:
>>>>> >>
>>>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
>>>>> wrote:
>>>>> >>>
>>>>> >>> Do you have a space before "--data-binary" when you run the command?
>>>>> >>>
>>>>> >>>
>>>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>>>>> >>> <yoursurrogategod@gmail.com
>>>>> >>> > wrote:
>>>>> >>>
>>>>> >>> > I'm going through this book and I'm in this section:
>>>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>>>>> >>> >
>>>>> >>> > I try this in the command line and this is the error that I get:
>>>>> >>> > % curl -vX PUT
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>>>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
>>>>> >>> > zsh: no matches found:
>>>>> >>> >
>>>>> >>> >
>>>>> >>> >
>>>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>>>>> >>> >
>>>>> >>> > Am I making a stupid copy/paste mistake that's not immediately
>>>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm working
>>>>> >>> > in.
>>>>> >>> >
>>>>> >>
>>>>> >>
>>>>> >> Yes.
>>>>> >
>>>>> >
>>>>> > This is what's in the database at the moment (if it helps):
>>>>> >
>>>>> > {
>>>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>>>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>>>>> >    "title": "There is Nothing Left to Lose",
>>>>> >    "artist": "Foo Fighters"
>>>>> > }
>>>>> >
>>>>> >
>>>>> > And I've attached the file with the actual DB.
>>>>>
>>>>
>>>> Gotcha.  It worked.  Thanks.
>>>>
>>>
>>> One more question, would it be possible to include multiple binary
>>> uploaded files?
>>>
>>> This is what I tried and the results that I got:
>>>
>>> % curl -vX PUT "
>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680"
>>> --data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
>>> image/jpg"
>>> * About to connect() to 127.0.0.1 port 5984 (#0)
>>> *   Trying 127.0.0.1...
>>> * Adding handle: conn: 0x7fe5c4007c00
>>> * Adding handle: send: 0
>>> * Adding handle: recv: 0
>>> * Curl_addHandleToPipeline: length: 1
>>> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
>>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>>> > PUT
>>> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
>>> HTTP/1.1
>>> > User-Agent: curl/7.31.0
>>> > Host: 127.0.0.1:5984
>>> > Accept: */*
>>> > Content-Type: image/jpg
>>> > Content-Length: 161673
>>> > Expect: 100-continue
>>> >
>>> < HTTP/1.1 100 Continue
>>> < HTTP/1.1 409 Conflict
>>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>>> < Date: Tue, 16 Jul 2013 19:19:45 GMT
>>> < Content-Type: text/plain; charset=utf-8
>>> < Content-Length: 58
>>> < Cache-Control: must-revalidate
>>> * HTTP error before end of send, stop sending
>>> <
>>> {"error":"conflict","reason":"Document update conflict."}
>>> * Closing connection 0
>>>
>>> This is the current record:
>>>
>>> {
>>>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>>>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
>>>    "title": "There is Nothing Left to Lose",
>>>    "artist": "Foo Fighters",
>>>    "_attachments": {
>>>        "artwork.jpg": {
>>>            "content_type": "image/jpg",
>>>            "revpos": 2,
>>>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
>>>            "length": 15138,
>>>            "stub": true
>>>        }
>>>    }
>>> }
>>>
>>
>> This is off-topic, but when I tried to setup a replication DB, this is the
>> error that I got:
>>
>> % curl -X PUT http://127.0.0.1:5984/albums-replica
>> {"ok":true}
>> % curl -vX POST http://127.0.0.1:5984/_replicate -d '{"source":"albums",
>> "target":"albums-replica"}'
>> * About to connect() to 127.0.0.1 port 5984 (#0)
>> *   Trying 127.0.0.1...
>> * Adding handle: conn: 0x7fb592808c00
>> * Adding handle: send: 0
>> * Adding handle: recv: 0
>> * Curl_addHandleToPipeline: length: 1
>> * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>>> POST /_replicate HTTP/1.1
>>> User-Agent: curl/7.31.0
>>> Host: 127.0.0.1:5984
>>> Accept: */*
>>> Content-Length: 46
>>> Content-Type: application/x-www-form-urlencoded
>>>
>> * upload completely sent off: 46 out of 46 bytes
>> < HTTP/1.1 415 Unsupported Media Type
>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>> < Date: Tue, 16 Jul 2013 19:23:34 GMT
>> < Content-Type: text/plain; charset=utf-8
>> < Content-Length: 78
>> < Cache-Control: must-revalidate
>> <
>> {"error":"bad_content_type","reason":"Content-Type must be
>> application/json"}
>>
>> Thoughts?
>>
>> But also, is there an index of general CouchDB errors that I can refer to
>> and find
>> out the general causes behind those errors?

Re: Can't upload a pic to CouchDB.

Posted by Robert Newson <rn...@apache.org>.
I think the error message is very descriptive and tells you exactly what to do.

B.


On 16 July 2013 20:38, Yves S. Garret <yo...@gmail.com> wrote:
> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
> <yo...@gmail.com>wrote:
>
>> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
>> yoursurrogategod@gmail.com> wrote:
>>
>>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rn...@apache.org>wrote:
>>>
>>>> You need to pass the current rev, which clearly doesn't match the one
>>>> you tried and got the 409 conflict telling you it was wrong for.
>>>>
>>>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com>
>>>> wrote:
>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
>>>> > <yo...@gmail.com> wrote:
>>>> >>
>>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
>>>> wrote:
>>>> >>>
>>>> >>> Do you have a space before "--data-binary" when you run the command?
>>>> >>>
>>>> >>>
>>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>>>> >>> <yoursurrogategod@gmail.com
>>>> >>> > wrote:
>>>> >>>
>>>> >>> > I'm going through this book and I'm in this section:
>>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>>>> >>> >
>>>> >>> > I try this in the command line and this is the error that I get:
>>>> >>> > % curl -vX PUT
>>>> >>> >
>>>> >>> >
>>>> >>> >
>>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
>>>> >>> > zsh: no matches found:
>>>> >>> >
>>>> >>> >
>>>> >>> >
>>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>>>> >>> >
>>>> >>> > Am I making a stupid copy/paste mistake that's not immediately
>>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm working
>>>> >>> > in.
>>>> >>> >
>>>> >>
>>>> >>
>>>> >> Yes.
>>>> >
>>>> >
>>>> > This is what's in the database at the moment (if it helps):
>>>> >
>>>> > {
>>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>>>> >    "title": "There is Nothing Left to Lose",
>>>> >    "artist": "Foo Fighters"
>>>> > }
>>>> >
>>>> >
>>>> > And I've attached the file with the actual DB.
>>>>
>>>
>>> Gotcha.  It worked.  Thanks.
>>>
>>
>> One more question, would it be possible to include multiple binary
>> uploaded files?
>>
>> This is what I tried and the results that I got:
>>
>> % curl -vX PUT "
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680"
>> --data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
>> image/jpg"
>> * About to connect() to 127.0.0.1 port 5984 (#0)
>> *   Trying 127.0.0.1...
>> * Adding handle: conn: 0x7fe5c4007c00
>> * Adding handle: send: 0
>> * Adding handle: recv: 0
>> * Curl_addHandleToPipeline: length: 1
>> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
>> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> > PUT
>> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
>> HTTP/1.1
>> > User-Agent: curl/7.31.0
>> > Host: 127.0.0.1:5984
>> > Accept: */*
>> > Content-Type: image/jpg
>> > Content-Length: 161673
>> > Expect: 100-continue
>> >
>> < HTTP/1.1 100 Continue
>> < HTTP/1.1 409 Conflict
>> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
>> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
>> < Date: Tue, 16 Jul 2013 19:19:45 GMT
>> < Content-Type: text/plain; charset=utf-8
>> < Content-Length: 58
>> < Cache-Control: must-revalidate
>> * HTTP error before end of send, stop sending
>> <
>> {"error":"conflict","reason":"Document update conflict."}
>> * Closing connection 0
>>
>> This is the current record:
>>
>> {
>>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
>>    "title": "There is Nothing Left to Lose",
>>    "artist": "Foo Fighters",
>>    "_attachments": {
>>        "artwork.jpg": {
>>            "content_type": "image/jpg",
>>            "revpos": 2,
>>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
>>            "length": 15138,
>>            "stub": true
>>        }
>>    }
>> }
>>
>
> This is off-topic, but when I tried to setup a replication DB, this is the
> error that I got:
>
> % curl -X PUT http://127.0.0.1:5984/albums-replica
> {"ok":true}
> % curl -vX POST http://127.0.0.1:5984/_replicate -d '{"source":"albums",
> "target":"albums-replica"}'
> * About to connect() to 127.0.0.1 port 5984 (#0)
> *   Trying 127.0.0.1...
> * Adding handle: conn: 0x7fb592808c00
> * Adding handle: send: 0
> * Adding handle: recv: 0
> * Curl_addHandleToPipeline: length: 1
> * - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
>> POST /_replicate HTTP/1.1
>> User-Agent: curl/7.31.0
>> Host: 127.0.0.1:5984
>> Accept: */*
>> Content-Length: 46
>> Content-Type: application/x-www-form-urlencoded
>>
> * upload completely sent off: 46 out of 46 bytes
> < HTTP/1.1 415 Unsupported Media Type
> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> < Date: Tue, 16 Jul 2013 19:23:34 GMT
> < Content-Type: text/plain; charset=utf-8
> < Content-Length: 78
> < Cache-Control: must-revalidate
> <
> {"error":"bad_content_type","reason":"Content-Type must be
> application/json"}
>
> Thoughts?
>
> But also, is there an index of general CouchDB errors that I can refer to
> and find
> out the general causes behind those errors?

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret
<yo...@gmail.com>wrote:

> On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret <
> yoursurrogategod@gmail.com> wrote:
>
>> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rn...@apache.org>wrote:
>>
>>> You need to pass the current rev, which clearly doesn't match the one
>>> you tried and got the 409 conflict telling you it was wrong for.
>>>
>>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com>
>>> wrote:
>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
>>> > <yo...@gmail.com> wrote:
>>> >>
>>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
>>> wrote:
>>> >>>
>>> >>> Do you have a space before "--data-binary" when you run the command?
>>> >>>
>>> >>>
>>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>>> >>> <yoursurrogategod@gmail.com
>>> >>> > wrote:
>>> >>>
>>> >>> > I'm going through this book and I'm in this section:
>>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>>> >>> >
>>> >>> > I try this in the command line and this is the error that I get:
>>> >>> > % curl -vX PUT
>>> >>> >
>>> >>> >
>>> >>> >
>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
>>> >>> > zsh: no matches found:
>>> >>> >
>>> >>> >
>>> >>> >
>>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>>> >>> >
>>> >>> > Am I making a stupid copy/paste mistake that's not immediately
>>> >>> > obvious?  There is an artwork.jpg in the directory that I'm working
>>> >>> > in.
>>> >>> >
>>> >>
>>> >>
>>> >> Yes.
>>> >
>>> >
>>> > This is what's in the database at the moment (if it helps):
>>> >
>>> > {
>>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>>> >    "title": "There is Nothing Left to Lose",
>>> >    "artist": "Foo Fighters"
>>> > }
>>> >
>>> >
>>> > And I've attached the file with the actual DB.
>>>
>>
>> Gotcha.  It worked.  Thanks.
>>
>
> One more question, would it be possible to include multiple binary
> uploaded files?
>
> This is what I tried and the results that I got:
>
> % curl -vX PUT "
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680"
> --data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
> image/jpg"
> * About to connect() to 127.0.0.1 port 5984 (#0)
> *   Trying 127.0.0.1...
> * Adding handle: conn: 0x7fe5c4007c00
> * Adding handle: send: 0
> * Adding handle: recv: 0
> * Curl_addHandleToPipeline: length: 1
> * - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> > PUT
> /albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
> HTTP/1.1
> > User-Agent: curl/7.31.0
> > Host: 127.0.0.1:5984
> > Accept: */*
> > Content-Type: image/jpg
> > Content-Length: 161673
> > Expect: 100-continue
> >
> < HTTP/1.1 100 Continue
> < HTTP/1.1 409 Conflict
> * Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
> < Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
> < Date: Tue, 16 Jul 2013 19:19:45 GMT
> < Content-Type: text/plain; charset=utf-8
> < Content-Length: 58
> < Cache-Control: must-revalidate
> * HTTP error before end of send, stop sending
> <
> {"error":"conflict","reason":"Document update conflict."}
> * Closing connection 0
>
> This is the current record:
>
> {
>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>    "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
>    "title": "There is Nothing Left to Lose",
>    "artist": "Foo Fighters",
>    "_attachments": {
>        "artwork.jpg": {
>            "content_type": "image/jpg",
>            "revpos": 2,
>            "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
>            "length": 15138,
>            "stub": true
>        }
>    }
> }
>

This is off-topic, but when I tried to setup a replication DB, this is the
error that I got:

% curl -X PUT http://127.0.0.1:5984/albums-replica
{"ok":true}
% curl -vX POST http://127.0.0.1:5984/_replicate -d '{"source":"albums",
"target":"albums-replica"}'
* About to connect() to 127.0.0.1 port 5984 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7fb592808c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fb592808c00) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> POST /_replicate HTTP/1.1
> User-Agent: curl/7.31.0
> Host: 127.0.0.1:5984
> Accept: */*
> Content-Length: 46
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 46 out of 46 bytes
< HTTP/1.1 415 Unsupported Media Type
* Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
< Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
< Date: Tue, 16 Jul 2013 19:23:34 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 78
< Cache-Control: must-revalidate
<
{"error":"bad_content_type","reason":"Content-Type must be
application/json"}

Thoughts?

But also, is there an index of general CouchDB errors that I can refer to
and find
out the general causes behind those errors?

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 1:34 PM, Yves S. Garret
<yo...@gmail.com>wrote:

> On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rn...@apache.org> wrote:
>
>> You need to pass the current rev, which clearly doesn't match the one
>> you tried and got the 409 conflict telling you it was wrong for.
>>
>> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com> wrote:
>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
>> > <yo...@gmail.com> wrote:
>> >>
>> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
>> wrote:
>> >>>
>> >>> Do you have a space before "--data-binary" when you run the command?
>> >>>
>> >>>
>> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>> >>> <yoursurrogategod@gmail.com
>> >>> > wrote:
>> >>>
>> >>> > I'm going through this book and I'm in this section:
>> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>> >>> >
>> >>> > I try this in the command line and this is the error that I get:
>> >>> > % curl -vX PUT
>> >>> >
>> >>> >
>> >>> >
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>> >>> > @artwork.jpg -H "Content-Type: image/jpg"
>> >>> > zsh: no matches found:
>> >>> >
>> >>> >
>> >>> >
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>> >>> >
>> >>> > Am I making a stupid copy/paste mistake that's not immediately
>> >>> > obvious?  There is an artwork.jpg in the directory that I'm working
>> >>> > in.
>> >>> >
>> >>
>> >>
>> >> Yes.
>> >
>> >
>> > This is what's in the database at the moment (if it helps):
>> >
>> > {
>> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>> >    "title": "There is Nothing Left to Lose",
>> >    "artist": "Foo Fighters"
>> > }
>> >
>> >
>> > And I've attached the file with the actual DB.
>>
>
> Gotcha.  It worked.  Thanks.
>

One more question, would it be possible to include multiple binary uploaded
files?

This is what I tried and the results that I got:

% curl -vX PUT "
http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680"
--data-binary @artwork.jpg --data-binary @sample2.jpg -H "Content-Type:
image/jpg"
* About to connect() to 127.0.0.1 port 5984 (#0)
*   Trying 127.0.0.1...
* Adding handle: conn: 0x7fe5c4007c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fe5c4007c00) send_pipe: 1, recv_pipe: 0
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> PUT
/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-5ba0d72de94d89056e1f91ec900f5680
HTTP/1.1
> User-Agent: curl/7.31.0
> Host: 127.0.0.1:5984
> Accept: */*
> Content-Type: image/jpg
> Content-Length: 161673
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 409 Conflict
* Server CouchDB/1.3.1 (Erlang OTP/R16B01) is not blacklisted
< Server: CouchDB/1.3.1 (Erlang OTP/R16B01)
< Date: Tue, 16 Jul 2013 19:19:45 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 58
< Cache-Control: must-revalidate
* HTTP error before end of send, stop sending
<
{"error":"conflict","reason":"Document update conflict."}
* Closing connection 0

This is the current record:

{
   "_id": "6e1295ed6c29495e54cc05947f18c8af",
   "_rev": "2-5ba0d72de94d89056e1f91ec900f5680",
   "title": "There is Nothing Left to Lose",
   "artist": "Foo Fighters",
   "_attachments": {
       "artwork.jpg": {
           "content_type": "image/jpg",
           "revpos": 2,
           "digest": "md5-dqqlZ2iJ4Mw9C6SNf7r+Pw==",
           "length": 15138,
           "stub": true
       }
   }
}

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 1:12 PM, Robert Newson <rn...@apache.org> wrote:

> You need to pass the current rev, which clearly doesn't match the one
> you tried and got the 409 conflict telling you it was wrong for.
>
> On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com> wrote:
> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
> > <yo...@gmail.com> wrote:
> >>
> >> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com>
> wrote:
> >>>
> >>> Do you have a space before "--data-binary" when you run the command?
> >>>
> >>>
> >>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
> >>> <yoursurrogategod@gmail.com
> >>> > wrote:
> >>>
> >>> > I'm going through this book and I'm in this section:
> >>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
> >>> >
> >>> > I try this in the command line and this is the error that I get:
> >>> > % curl -vX PUT
> >>> >
> >>> >
> >>> >
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> >>> > @artwork.jpg -H "Content-Type: image/jpg"
> >>> > zsh: no matches found:
> >>> >
> >>> >
> >>> >
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
> >>> >
> >>> > Am I making a stupid copy/paste mistake that's not immediately
> >>> > obvious?  There is an artwork.jpg in the directory that I'm working
> >>> > in.
> >>> >
> >>
> >>
> >> Yes.
> >
> >
> > This is what's in the database at the moment (if it helps):
> >
> > {
> >    "_id": "6e1295ed6c29495e54cc05947f18c8af",
> >    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
> >    "title": "There is Nothing Left to Lose",
> >    "artist": "Foo Fighters"
> > }
> >
> >
> > And I've attached the file with the actual DB.
>

Gotcha.  It worked.  Thanks.

Re: Can't upload a pic to CouchDB.

Posted by Robert Newson <rn...@apache.org>.
You need to pass the current rev, which clearly doesn't match the one
you tried and got the 409 conflict telling you it was wrong for.

On 16 July 2013 18:07, Yves S. Garret <yo...@gmail.com> wrote:
> On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret
> <yo...@gmail.com> wrote:
>>
>> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com> wrote:
>>>
>>> Do you have a space before "--data-binary" when you run the command?
>>>
>>>
>>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret
>>> <yoursurrogategod@gmail.com
>>> > wrote:
>>>
>>> > I'm going through this book and I'm in this section:
>>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>>> >
>>> > I try this in the command line and this is the error that I get:
>>> > % curl -vX PUT
>>> >
>>> >
>>> > http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>>> > @artwork.jpg -H "Content-Type: image/jpg"
>>> > zsh: no matches found:
>>> >
>>> >
>>> > http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>>> >
>>> > Am I making a stupid copy/paste mistake that's not immediately
>>> > obvious?  There is an artwork.jpg in the directory that I'm working
>>> > in.
>>> >
>>
>>
>> Yes.
>
>
> This is what's in the database at the moment (if it helps):
>
> {
>    "_id": "6e1295ed6c29495e54cc05947f18c8af",
>    "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
>    "title": "There is Nothing Left to Lose",
>    "artist": "Foo Fighters"
> }
>
>
> And I've attached the file with the actual DB.

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret <yoursurrogategod@gmail.com
> wrote:

> On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com> wrote:
>
>> Do you have a space before "--data-binary" when you run the command?
>>
>>
>> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret <
>> yoursurrogategod@gmail.com
>> > wrote:
>>
>> > I'm going through this book and I'm in this section:
>> > http://guide.couchdb.org/editions/1/en/api.html#attachments
>> >
>> > I try this in the command line and this is the error that I get:
>> > % curl -vX PUT
>> >
>> >
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
>> > @artwork.jpg -H "Content-Type: image/jpg"
>> > zsh: no matches found:
>> >
>> >
>> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>> >
>> > Am I making a stupid copy/paste mistake that's not immediately
>> > obvious?  There is an artwork.jpg in the directory that I'm working
>> > in.
>> >
>>
>
> Yes.
>

This is what's in the database at the moment (if it helps):

{
   "_id": "6e1295ed6c29495e54cc05947f18c8af",
   "_rev": "1-4b39c2971c9ad54cb37e08fa02fec636",
   "title": "There is Nothing Left to Lose",
   "artist": "Foo Fighters"
}


And I've attached the file with the actual DB.

Re: Can't upload a pic to CouchDB.

Posted by "Yves S. Garret" <yo...@gmail.com>.
On Tue, Jul 16, 2013 at 11:13 AM, Tim Tisdall <ti...@gmail.com> wrote:

> Do you have a space before "--data-binary" when you run the command?
>
>
> On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret <
> yoursurrogategod@gmail.com
> > wrote:
>
> > I'm going through this book and I'm in this section:
> > http://guide.couchdb.org/editions/1/en/api.html#attachments
> >
> > I try this in the command line and this is the error that I get:
> > % curl -vX PUT
> >
> >
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> > @artwork.jpg -H "Content-Type: image/jpg"
> > zsh: no matches found:
> >
> >
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
> >
> > Am I making a stupid copy/paste mistake that's not immediately
> > obvious?  There is an artwork.jpg in the directory that I'm working
> > in.
> >
>

Yes.

Re: Can't upload a pic to CouchDB.

Posted by Tim Tisdall <ti...@gmail.com>.
Do you have a space before "--data-binary" when you run the command?


On Tue, Jul 16, 2013 at 11:05 AM, Yves S. Garret <yoursurrogategod@gmail.com
> wrote:

> I'm going through this book and I'm in this section:
> http://guide.couchdb.org/editions/1/en/api.html#attachments
>
> I try this in the command line and this is the error that I get:
> % curl -vX PUT
>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689--data-binary
> @artwork.jpg -H "Content-Type: image/jpg"
> zsh: no matches found:
>
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/artwork.jpg?rev=2-2739352689
>
> Am I making a stupid copy/paste mistake that's not immediately
> obvious?  There is an artwork.jpg in the directory that I'm working
> in.
>