There's already a max_document_size config setting. You can use the length of Json.stringify(doc) too.
Sent from my iPad On 23 Mar 2013, at 22:27, "Quentin Raynaud (JIRA)" <[email protected]> wrote: > Quentin Raynaud created COUCHDB-1722: > ---------------------------------------- > > Summary: Add a way to get the document size in validate_doc_update > Key: COUCHDB-1722 > URL: https://issues.apache.org/jira/browse/COUCHDB-1722 > Project: CouchDB > Issue Type: Improvement > Reporter: Quentin Raynaud > > > It would be cool to add a way to know what is the current document size in > validate_doc_update, maybe by invoking a specific function provided by > CouchDB like "documentLength(document)" on it. The function could also take a > boolean as a second argument to include the document's attachments length or > not in the count. > > That would allow to prevent document creation/update if the document looks > too big for its indented purpose. I would like such a possibility to defeat > users that try to flood the database in CouchApps or other applications > allowing such a direct access to CouchDB. > > I don't like the idea that right now, a smart user that finds an application > with an API allowing direct access to a CouchDB can easily create some code > to use your database as as extra hard drive for whatever he wants (at least I > believe I could do that with some efforts by simply uploading my files to a > random doc that I have write access to and by adding an index to reference > them. This can be done by adding a new attribute to the doc if the validation > is not too strict or by recycling an already existing attribute to such an > effect or even by uploading the index in a specific file too). > > -- > This message is automatically generated by JIRA. > If you think it was sent incorrectly, please contact your JIRA administrators > For more information on JIRA, see: http://www.atlassian.com/software/jira
