You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by John Le Brasseur <jo...@gmail.com> on 2017/01/12 03:17:56 UTC

Uploading attachment

Hi.
While trying to upload an attachment using curl I get the following:

curl -vX PUT
http://user:pwd@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
--data-binary @img.jpg -H "Content-Type: image/jpeg"

* STATE: INIT => CONNECT handle 0x600091250; line 1402 (connection #-5000)
* Added connection 0. The cache now contains 1 members
*   Trying 127.0.0.1...
* STATE: CONNECT => WAITCONNECT handle 0x600091250; line 1455 (connection
#0)
* Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600091250; line 1562
(connection #0)
* STATE: SENDPROTOCONNECT => DO handle 0x600091250; line 1580 (connection
#0)
* Server auth using Basic with user 'jlb333333'
> PUT
/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
HTTP/1.1
> Host: 127.0.0.1:5984
> Authorization: Basic amxiMzMzMzMzOk50WmwuNkR3
> User-Agent: curl/7.49.0
> Accept: */*
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 4 out of 4 bytes
* STATE: DO => DO_DONE handle 0x600091250; line 1659 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x600091250; line 1786 (connection
#0)
* STATE: WAITPERFORM => PERFORM handle 0x600091250; line 1796 (connection
#0)
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 201 Created
< Cache-Control: must-revalidate
< Content-Length: 96
< Content-Type: application/json
< Date: Thu, 12 Jan 2017 02:29:25 GMT
< Location:
http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg
* Server CouchDB/2.0.0 (Erlang OTP/17) is not blacklisted
< Server: CouchDB/2.0.0 (Erlang OTP/17)
< X-Couch-Request-ID: 7d9cc02465
< X-CouchDB-Body-Time: 0
<
{"ok":true,"id":"6e1295ed6c29495e54cc05947f18c8af","rev":"33-47753389b1d0b6d6427a4c018a4d0604"}
* STATE: PERFORM => DONE handle 0x600091250; line 1955 (connection #0)
* multi_done
* Connection #0 to host 127.0.0.1 left intact
* Expire cleared


The actual file size is 66518 bytes.


If I upload the same file using fauxton, it uploads correctly.
("IMG.jpg": {
      "content_type": "image/jpeg",
      "revpos": 24,
      "digest": "md5-jlDEFsvG0rz0KJMMaWIfSQ==",
      "length": 66518,
      "stub": true)

I have tried different spelling(Content-Type: image/jpg) and putting
in/removing quotation marks around http.... eg 'http... and "http...


John Le Brasseur

Re: Uploading attachment

Posted by Sebastian Rothbucher <se...@googlemail.com>.
Hi John,

I did switch to MINGW (simply from the git client) some years ago when
working on Windows (esp. at work). And having a bash just makes it so much
better / easier / more predictable.

Just in case you're still looking for ways

Best
   Sebastian

On Fri, Jan 13, 2017 at 11:08 AM, John Le Brasseur <johnlebrasseur@gmail.com
> wrote:

> Thank you very much Dave.
> I will have to look at those.
> I am trying using Bash on Windows 10 which is now possible, as an
> alternative.
>
>
> On 13 January 2017 at 10:44, Dave Cottlehuber <dc...@skunkwerks.at> wrote:
>
> > On Thu, 12 Jan 2017, at 15:05, John Le Brasseur wrote:
> > > Hi Stefan.
> > > I think it is something to do with the console.
> > > I am on Windows but use the cmder(http://cmder.net/) console program
> > > which
> > > doesn't normally require me to escape special characters.
> > >
> > > I tried the normal DOS command window, which I normally avoid, and
> guess
> > > what, it worked with the following command:
> > >
> > > curl -X PUT "
> > > http://jlb333333:NtZl.6Dw@127.0.0.1:5984/albums/
> > 6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=34-
> > 4f33ba65127ea2f8cb67cd9e82fa2244"
> > > --data-binary @img.jpg -H "Content-Type: image/jpeg"
> > >
> > > I knew my syntax was correct.
> > >
> > > Correct file size and type.
> > >
> > > The console gymnastics in Windows is the biggest problem for me.
> > >
> > > Thank you Stefan and Robert for the inputs.
> >
> >
> > Hi John,
> >
> > https://technet.microsoft.com/en-us/library/cc723564.aspx  is the
> > reference for dealing with windows escape rules.
> > see also the dated but correct wrt windows shell quoting
> > https://wiki.apache.org/couchdb/Quirks_on_Windows
> >
> > A+
> > Dave
> >
>
>
> John
>

Re: Uploading attachment

Posted by John Le Brasseur <jo...@gmail.com>.
Thank you very much Dave.
I will have to look at those.
I am trying using Bash on Windows 10 which is now possible, as an
alternative.


On 13 January 2017 at 10:44, Dave Cottlehuber <dc...@skunkwerks.at> wrote:

> On Thu, 12 Jan 2017, at 15:05, John Le Brasseur wrote:
> > Hi Stefan.
> > I think it is something to do with the console.
> > I am on Windows but use the cmder(http://cmder.net/) console program
> > which
> > doesn't normally require me to escape special characters.
> >
> > I tried the normal DOS command window, which I normally avoid, and guess
> > what, it worked with the following command:
> >
> > curl -X PUT "
> > http://jlb333333:NtZl.6Dw@127.0.0.1:5984/albums/
> 6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=34-
> 4f33ba65127ea2f8cb67cd9e82fa2244"
> > --data-binary @img.jpg -H "Content-Type: image/jpeg"
> >
> > I knew my syntax was correct.
> >
> > Correct file size and type.
> >
> > The console gymnastics in Windows is the biggest problem for me.
> >
> > Thank you Stefan and Robert for the inputs.
>
>
> Hi John,
>
> https://technet.microsoft.com/en-us/library/cc723564.aspx  is the
> reference for dealing with windows escape rules.
> see also the dated but correct wrt windows shell quoting
> https://wiki.apache.org/couchdb/Quirks_on_Windows
>
> A+
> Dave
>


John

Re: Uploading attachment

Posted by Dave Cottlehuber <dc...@skunkwerks.at>.
On Thu, 12 Jan 2017, at 15:05, John Le Brasseur wrote:
> Hi Stefan.
> I think it is something to do with the console.
> I am on Windows but use the cmder(http://cmder.net/) console program
> which
> doesn't normally require me to escape special characters.
> 
> I tried the normal DOS command window, which I normally avoid, and guess
> what, it worked with the following command:
> 
> curl -X PUT "
> http://jlb333333:NtZl.6Dw@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=34-4f33ba65127ea2f8cb67cd9e82fa2244"
> --data-binary @img.jpg -H "Content-Type: image/jpeg"
> 
> I knew my syntax was correct.
> 
> Correct file size and type.
> 
> The console gymnastics in Windows is the biggest problem for me.
> 
> Thank you Stefan and Robert for the inputs.


Hi John,

https://technet.microsoft.com/en-us/library/cc723564.aspx  is the
reference for dealing with windows escape rules.
see also the dated but correct wrt windows shell quoting
https://wiki.apache.org/couchdb/Quirks_on_Windows

A+
Dave

Re: Uploading attachment

Posted by John Le Brasseur <jo...@gmail.com>.
Hi Stefan.
I think it is something to do with the console.
I am on Windows but use the cmder(http://cmder.net/) console program which
doesn't normally require me to escape special characters.

I tried the normal DOS command window, which I normally avoid, and guess
what, it worked with the following command:

curl -X PUT "
http://jlb333333:NtZl.6Dw@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=34-4f33ba65127ea2f8cb67cd9e82fa2244"
--data-binary @img.jpg -H "Content-Type: image/jpeg"

I knew my syntax was correct.

Correct file size and type.

The console gymnastics in Windows is the biggest problem for me.

Thank you Stefan and Robert for the inputs.



On 12 January 2017 at 15:37, Stefan Klein <st...@gmail.com> wrote:

> Hi,
>
> 2017-01-12 14:30 GMT+01:00 John Le Brasseur <jo...@gmail.com>:
> > Hi Robert.
> >
> > Very poor description by me early this morning. Sorry.
> >
> > The problem is the upload file size and type:
> >
> >> Content-Length: 4
> >> Content-Type: application/x-www-form-urlencoded
>
> >> > curl -vX PUT
> >> > http://user:pwd@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8
> >> af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
> >> > --data-binary @img.jpg -H "Content-Type: image/jpeg"
>
> I ran the "same" curl commandline and it works as expected.
>
> Maybe you got an alias set for curl?
> Old version of curl?
>
> Which os/shell are you runing, maybe it interprets the question mark or
> the at?
>
> regards,
> Stefan
>



John

Re: Uploading attachment

Posted by Stefan Klein <st...@gmail.com>.
Hi,

2017-01-12 14:30 GMT+01:00 John Le Brasseur <jo...@gmail.com>:
> Hi Robert.
>
> Very poor description by me early this morning. Sorry.
>
> The problem is the upload file size and type:
>
>> Content-Length: 4
>> Content-Type: application/x-www-form-urlencoded

>> > curl -vX PUT
>> > http://user:pwd@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8
>> af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
>> > --data-binary @img.jpg -H "Content-Type: image/jpeg"

I ran the "same" curl commandline and it works as expected.

Maybe you got an alias set for curl?
Old version of curl?

Which os/shell are you runing, maybe it interprets the question mark or the at?

regards,
Stefan

Re: Uploading attachment

Posted by John Le Brasseur <jo...@gmail.com>.
Hi Robert.

Very poor description by me early this morning. Sorry.

The problem is the upload file size and type:

> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded

Should be :

 "content_type": "image/jpeg",
      "length": 66518,

It indicates success but it isn't.

Content length is only 4 and type is application/x-www-form-urlencoded

I cannot get a reason for this.

Thanks for the input.



On 12 January 2017 at 15:02, Robert Samuel Newson <rn...@apache.org>
wrote:

> That looks like a successful upload. What problem are you reporting here?
>
> > On 12 Jan 2017, at 03:17, John Le Brasseur <jo...@gmail.com>
> wrote:
> >
> > Hi.
> > While trying to upload an attachment using curl I get the following:
> >
> > curl -vX PUT
> > http://user:pwd@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8
> af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
> > --data-binary @img.jpg -H "Content-Type: image/jpeg"
> >
> > * STATE: INIT => CONNECT handle 0x600091250; line 1402 (connection
> #-5000)
> > * Added connection 0. The cache now contains 1 members
> > *   Trying 127.0.0.1...
> > * STATE: CONNECT => WAITCONNECT handle 0x600091250; line 1455 (connection
> > #0)
> > * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> > * STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600091250; line 1562
> > (connection #0)
> > * STATE: SENDPROTOCONNECT => DO handle 0x600091250; line 1580 (connection
> > #0)
> > * Server auth using Basic with user 'jlb333333'
> >> PUT
> > /albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=32-
> f32a6d93b0f9483c4580adb5e0075fe4
> > HTTP/1.1
> >> Host: 127.0.0.1:5984
> >> Authorization: Basic amxiMzMzMzMzOk50WmwuNkR3
> >> User-Agent: curl/7.49.0
> >> Accept: */*
> >> Content-Length: 4
> >> Content-Type: application/x-www-form-urlencoded
> >>
> > * upload completely sent off: 4 out of 4 bytes
> > * STATE: DO => DO_DONE handle 0x600091250; line 1659 (connection #0)
> > * STATE: DO_DONE => WAITPERFORM handle 0x600091250; line 1786 (connection
> > #0)
> > * STATE: WAITPERFORM => PERFORM handle 0x600091250; line 1796 (connection
> > #0)
> > * HTTP 1.1 or later with persistent connection, pipelining supported
> > < HTTP/1.1 201 Created
> > < Cache-Control: must-revalidate
> > < Content-Length: 96
> > < Content-Type: application/json
> > < Date: Thu, 12 Jan 2017 02:29:25 GMT
> > < Location:
> > http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg
> > * Server CouchDB/2.0.0 (Erlang OTP/17) is not blacklisted
> > < Server: CouchDB/2.0.0 (Erlang OTP/17)
> > < X-Couch-Request-ID: 7d9cc02465
> > < X-CouchDB-Body-Time: 0
> > <
> > {"ok":true,"id":"6e1295ed6c29495e54cc05947f18c8af","rev":"33-
> 47753389b1d0b6d6427a4c018a4d0604"}
> > * STATE: PERFORM => DONE handle 0x600091250; line 1955 (connection #0)
> > * multi_done
> > * Connection #0 to host 127.0.0.1 left intact
> > * Expire cleared
> >
> >
> > The actual file size is 66518 bytes.
> >
> >
> > If I upload the same file using fauxton, it uploads correctly.
> > ("IMG.jpg": {
> >      "content_type": "image/jpeg",
> >      "revpos": 24,
> >      "digest": "md5-jlDEFsvG0rz0KJMMaWIfSQ==",
> >      "length": 66518,
> >      "stub": true)
> >
> > I have tried different spelling(Content-Type: image/jpg) and putting
> > in/removing quotation marks around http.... eg 'http... and "http...
> >
> >
> > John Le Brasseur
>
>


John

Re: Uploading attachment

Posted by Robert Samuel Newson <rn...@apache.org>.
That looks like a successful upload. What problem are you reporting here?

> On 12 Jan 2017, at 03:17, John Le Brasseur <jo...@gmail.com> wrote:
> 
> Hi.
> While trying to upload an attachment using curl I get the following:
> 
> curl -vX PUT
> http://user:pwd@127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
> --data-binary @img.jpg -H "Content-Type: image/jpeg"
> 
> * STATE: INIT => CONNECT handle 0x600091250; line 1402 (connection #-5000)
> * Added connection 0. The cache now contains 1 members
> *   Trying 127.0.0.1...
> * STATE: CONNECT => WAITCONNECT handle 0x600091250; line 1455 (connection
> #0)
> * Connected to 127.0.0.1 (127.0.0.1) port 5984 (#0)
> * STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600091250; line 1562
> (connection #0)
> * STATE: SENDPROTOCONNECT => DO handle 0x600091250; line 1580 (connection
> #0)
> * Server auth using Basic with user 'jlb333333'
>> PUT
> /albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg?rev=32-f32a6d93b0f9483c4580adb5e0075fe4
> HTTP/1.1
>> Host: 127.0.0.1:5984
>> Authorization: Basic amxiMzMzMzMzOk50WmwuNkR3
>> User-Agent: curl/7.49.0
>> Accept: */*
>> Content-Length: 4
>> Content-Type: application/x-www-form-urlencoded
>> 
> * upload completely sent off: 4 out of 4 bytes
> * STATE: DO => DO_DONE handle 0x600091250; line 1659 (connection #0)
> * STATE: DO_DONE => WAITPERFORM handle 0x600091250; line 1786 (connection
> #0)
> * STATE: WAITPERFORM => PERFORM handle 0x600091250; line 1796 (connection
> #0)
> * HTTP 1.1 or later with persistent connection, pipelining supported
> < HTTP/1.1 201 Created
> < Cache-Control: must-revalidate
> < Content-Length: 96
> < Content-Type: application/json
> < Date: Thu, 12 Jan 2017 02:29:25 GMT
> < Location:
> http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/img.jpg
> * Server CouchDB/2.0.0 (Erlang OTP/17) is not blacklisted
> < Server: CouchDB/2.0.0 (Erlang OTP/17)
> < X-Couch-Request-ID: 7d9cc02465
> < X-CouchDB-Body-Time: 0
> <
> {"ok":true,"id":"6e1295ed6c29495e54cc05947f18c8af","rev":"33-47753389b1d0b6d6427a4c018a4d0604"}
> * STATE: PERFORM => DONE handle 0x600091250; line 1955 (connection #0)
> * multi_done
> * Connection #0 to host 127.0.0.1 left intact
> * Expire cleared
> 
> 
> The actual file size is 66518 bytes.
> 
> 
> If I upload the same file using fauxton, it uploads correctly.
> ("IMG.jpg": {
>      "content_type": "image/jpeg",
>      "revpos": 24,
>      "digest": "md5-jlDEFsvG0rz0KJMMaWIfSQ==",
>      "length": 66518,
>      "stub": true)
> 
> I have tried different spelling(Content-Type: image/jpg) and putting
> in/removing quotation marks around http.... eg 'http... and "http...
> 
> 
> John Le Brasseur