You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Robert Newson (JIRA)" <ji...@apache.org> on 2013/03/24 16:53:15 UTC

[jira] [Closed] (COUCHDB-1722) Add a way to get the document size in validate_doc_update

     [ https://issues.apache.org/jira/browse/COUCHDB-1722?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Newson closed COUCHDB-1722.
----------------------------------

    Resolution: Invalid

You can calculate the size of the doc parameter using JSON.stringify(doc).length

                
> 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