Code Monkey home page Code Monkey logo

anyevent-couchdb's People

Contributors

beppu avatar c0decafe avatar fcuny avatar lukec avatar mzedeler avatar nothingmuch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

anyevent-couchdb's Issues

Couch 412 error "missing_stub" on saving document with attachment which was previously uploaded as inline attachment

If you save a document with an inline attachment, the changes from 1.26 lib/AnyEvent/CouchDB/Database.pm save_doc $_attachments subroutine delete the attachment 'data' property and replace it with length, revpos, and stub:true.

Since revpos is extracted with a regex, it's in string context. The next time you save the document, the revpos in the attachment stub is sent to the server as a string. Unfortunately, on couchdb 1.1.1, this causes an error 412 since CouchDB expects revpos to be a number, and gives a {"error":"missing_stub","reason":"id:test, name:test3.gif"} response.

e.g. with a document with a 'test3.gif' attachment uploaded at revpos 2, curl -X PUT localhost:5984/database/test -d '{"_id":"test", "_rev":"14-47afaef5d143f63a9f9104e90c1ce71a", "_attachments":{"test3.gif":{"revpos":"2","length":6,"stub":true}}}' fails, but curl -X PUT localhost:5984/database/test -d '{"_id":"test", "_rev":"14-47afaef5d143f63a9f9104e90c1ce71a", "_attachments":{"test3.gif":{"revpos":2,"length":6,"stub":true}}}' works.

One possible solution is to use revpos in a numeric context before saving so it'll be serialized as a number, the other solution is to just delete it before sending since CouchDB seems happy to accept {stub:true}.

Incidentally, CouchDB 1.1.1 adds an MD5 'digest' field to the returned stub; it can be left out when saving the document though as long as {stub:true} is present.

Handle GET with open_revs

At the moment you can do the following, which will not work as the JSON parser is given the raw multi-part response.

$db->open_doc($id, {'open_revs' => 'all'})->recv;

Presumably this should return an array of all the versions (and probably ignore any attachments in the response).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.