bulk update failing when document has attachments?

2013-12-11 Thread Daniel Gonzalez
Hi, (SO reference: http://stackoverflow.com/q/20516980/647991. I post there because formatting makes things much easier to read, replies / comments are well organized, and the up/downvote mechanism works) I am performing the following operation: 1. Prepare some documents: `docs = [ doc1, doc2,

Re: bulk update failing when document has attachments?

2013-12-11 Thread Alexander Shorin
Hi, _attachments data should be valid base64 encoded string, while you have: data:image/png;base64,iVBORw0KGgoNSUhEUgAAAM8AAADkCAIAAACwiOf9A3NCSVQICAjb4U/gAAAgAElEQVR4nO... Chars : and , are invalid for base64. -- ,,,^..^,,, On Wed, Dec 11, 2013 at 2:49 PM, Daniel Gonzalez

Re: bulk update failing when document has attachments?

2013-12-11 Thread Daniel Gonzalez
Thanks, I just realized about this. The base64 is coming from the javascript frontend (chose file in a form). So I need to remove the prefix data:image/png;base64,. Not sure how to do this without rolling my own regexes though. On Wed, Dec 11, 2013 at 12:01 PM, Alexander Shorin kxe...@gmail.com

Re: bulk update failing when document has attachments?

2013-12-11 Thread Johannes Jörg Schmidt
data.slice(22) 2013/12/11 Daniel Gonzalez gonva...@gonvaled.com: Thanks, I just realized about this. The base64 is coming from the javascript frontend (chose file in a form). So I need to remove the prefix data:image/png;base64,. Not sure how to do this without rolling my own regexes though.

Re: bulk update failing when document has attachments?

2013-12-11 Thread Daniel Gonzalez
That would work *only* for that prefix (data:image/png;base64,), or any prefix which happens to have the same length. Not very robust. I just discovered that the data coming from the front-end comes in data-uri format (rfc2397). This should handle any rfc2397 prefix:

Re: bulk update failing when document has attachments?

2013-12-11 Thread Robert Newson
I think your image\/png is just an artifact of your printing method, you don't need to escape the forward slash in content_type, see example below;

Re: bulk update failing when document has attachments?

2013-12-11 Thread Daniel Gonzalez
It is not an artifact: I am taking that from the couchdb documentation. And according to Alexander Shorin forward slashes **really** need to be escaped in json. But it is not me who must do that, but the library converting the python objects to couchdb, so that can not be my problem. Now I am

Re: bulk update failing when document has attachments?

2013-12-11 Thread Daniel Gonzalez
Thanks for your support. Problem solved. The explanation: now I was removing correctly the data-uri prefix, but the base64 encoded test data that I was using was actually not valid base64 data (it was manually defined, just for testing). It turns out that couchdb decodes (of course! hindsight is

Re: bulk update failing when document has attachments?

2013-12-11 Thread Robert Newson
http://json.org/string.gif talks escaping back slash, not forward slash. The PDF page 194 talks about escaping forward slash within a RegExp statement in Javascript, which is not JSON. B. On 11 December 2013 12:58, Daniel Gonzalez gonva...@gonvaled.com wrote: It is not an artifact: I am taking

Re: bulk update failing when document has attachments?

2013-12-11 Thread Robert Newson
➜ ~ curl localhost:5984/db1/_bulk_docs -Hcontent-type:application/json -d '{docs:[{_attachments:{foo:{data:aGVsbG8=}}}]}' [{ok:true,id:b5d2060479624e483a8fe4747f001dbe,rev:1-12c665c499a525a3a1a9ad35c90604a1}] ➜ ~ curl localhost:5984/db1/b5d2060479624e483a8fe4747f001dbe

Re: bulk update failing when document has attachments?

2013-12-11 Thread Alexander Shorin
On Wed, Dec 11, 2013 at 5:11 PM, Robert Newson rnew...@apache.org wrote: http://json.org/string.gif talks escaping back slash, not forward slash. The PDF page 194 talks about escaping forward slash within a RegExp statement in Javascript, which is not JSON. Sorry, wrong page - I had searched

Re: bulk update failing when document has attachments?

2013-12-11 Thread Daniel Gonzalez
Funny that you do not need to escape it. The spec says you should: char any-Unicode-character- except--or-\-or- control-character \ \\ \/ \b \f \n \r \t \u four-hex-digits Anyway, my problem has been solved. I am not escaping anything in the content_type: the json library is problably

Re: bulk update failing when document has attachments?

2013-12-11 Thread Robert Newson
forward slash is a Unicode-character-except--or-\-or-control-character. The picture does show that you *can* escape a forward slash with \/ but the 'any' track allows an unescaped forward slash. It's not news that JSON (while ostensibly simple) is not well-defined, though. I suggest we all just

Re: use startkey/endkey to discribe a range problem

2013-12-11 Thread Florian Westreicher Bakk.techn.
That's an interesting idea but it will not work in all situations. You could not query for areas that span multiple quadrants. If you would like to get all locations around 0,0 in a 20km square this won't work. Vivek Pathak vpat...@orgmeta.com wrote: You can replicate the two dimensional

Re: use startkey/endkey to discribe a range problem

2013-12-11 Thread Alexander Shorin
On Wed, Dec 11, 2013 at 11:16 PM, Florian Westreicher Bakk.techn. st...@meredrica.org wrote: That's an interesting idea but it will not work in all situations. You could not query for areas that span multiple quadrants. If you would like to get all locations around 0,0 in a 20km square this

Re: use startkey/endkey to discribe a range problem

2013-12-11 Thread Andy Wenk
On 11 December 2013 20:22, Alexander Shorin kxe...@gmail.com wrote: This task looks suitable for GeoCouch extension: https://github.com/couchbase/geocouch Any idea if the project is still living? The last commit is five months old ... Cheers Andy -- Andy Wenk Hamburg - Germany RockIt!

Re: use startkey/endkey to discribe a range problem

2013-12-11 Thread Alexander Shorin
On Thu, Dec 12, 2013 at 12:27 AM, Andy Wenk a...@nms.de wrote: On 11 December 2013 20:22, Alexander Shorin kxe...@gmail.com wrote: This task looks suitable for GeoCouch extension: https://github.com/couchbase/geocouch Any idea if the project is still living? The last commit is five months

Re: bulk update failing when document has attachments?

2013-12-11 Thread Jens Alfke
On Dec 11, 2013, at 5:27 AM, Robert Newson rnew...@apache.org wrote: forward slash is a Unicode-character-except--or-\-or-control-character. The picture does show that you *can* escape a forward slash with \/ but the 'any' track allows an unescaped forward slash. +1. The only printing

Re: use startkey/endkey to discribe a range problem

2013-12-11 Thread Vivek Pathak
Hi I have been using this approach successfully via a view. The view emits the geokey based on latitude and longitude of the document (document has a location). The idea is to traverse the view in ascending and descending orders - from a start key corresponding to center of bounding box -

Re: use startkey/endkey to discribe a range problem

2013-12-11 Thread Dave Cottlehuber
Vivek, This approach sounds really interesting. Are you able to share a small example? Link to working code would be a bonus! Also, geocouch is hardly experimental these days, it's at least 2 years old and has been well used. A+ Dave On 12 December 2013 04:02, Vivek Pathak