Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8473310302 for ; Tue, 16 Jul 2013 20:35:31 +0000 (UTC) Received: (qmail 92418 invoked by uid 500); 16 Jul 2013 20:35:30 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 92374 invoked by uid 500); 16 Jul 2013 20:35:30 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 92366 invoked by uid 99); 16 Jul 2013 20:35:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jul 2013 20:35:29 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of yoursurrogategod@gmail.com designates 74.125.82.51 as permitted sender) Received: from [74.125.82.51] (HELO mail-wg0-f51.google.com) (74.125.82.51) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jul 2013 20:35:25 +0000 Received: by mail-wg0-f51.google.com with SMTP id e11so1055719wgh.30 for ; Tue, 16 Jul 2013 13:35:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=FrfdWft4tY6+rDOsW3flVxwJDUnfoFQeusaRSD/ZybQ=; b=rHlkf4KRfy8EfbNHMDXG8NUVRJnWhm9YeYQBsSons4MpJlFKUxkQqDGSk5dQeJX87v TEDGcfUqNBK0hucjl6idfNf1KWqZxNPK6aas56fzyQEla52hMT7x9iL7PyIU7MzAIXqC UvJvqDW3ASuzlQmTlCsNkkNJHsCRcOSVHnAmAwF8+50ysTf6+e0k6vT63rYv4zqt8Mdd EPuWnstRMWcW/TfLL0A3tooLzDFcv/P84XDfxBUnKYmiq7jhS+0evqgLul5lc+YYXOoN ORHkkVtOj+f5StSCgqFewdJKsHiz3x4+lZUKq65xkbnsM9HSEZfayCsrDmANvBA3+Bq9 FaEw== MIME-Version: 1.0 X-Received: by 10.180.187.209 with SMTP id fu17mr2356874wic.52.1374006904083; Tue, 16 Jul 2013 13:35:04 -0700 (PDT) Received: by 10.194.78.241 with HTTP; Tue, 16 Jul 2013 13:35:04 -0700 (PDT) In-Reply-To: References: Date: Tue, 16 Jul 2013 16:35:04 -0400 Message-ID: Subject: Re: Can't upload a pic to CouchDB. From: "Yves S. Garret" To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=001a11c269ac6fda9a04e1a6e9a3 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c269ac6fda9a04e1a6e9a3 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jul 16, 2013 at 4:32 PM, Robert Newson 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 wrote: > > On Tue, Jul 16, 2013 at 4:20 PM, Robert Newson > 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 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 > >> wrote: > >> >> On Tue, Jul 16, 2013 at 3:22 PM, Yves S. Garret > >> >> 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 >> >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 > > >> >>>>> wrote: > >> >>>>> > On Tue, Jul 16, 2013 at 11:39 AM, Yves S. Garret > >> >>>>> > 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 > >> >>>>> >>> >> >>>>> >>> > 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 :) . --001a11c269ac6fda9a04e1a6e9a3--