Filesystem to document

105 views
Skip to first unread message

D. Dingdreher

unread,
Sep 4, 2014, 2:24:05 PM9/4/14
to couc...@googlegroups.com
Hi Hello

Is there a tool, in the couchdb universe, that allows me to simply PUT a folder to couchdb as a normal doc, like these 2 clients for _design docs, erica and npm couchapp but not CURL.

- Docname
   - _attachments
   - foo.json
   - bar.json

Steve

unread,
Sep 5, 2014, 11:12:39 AM9/5/14
to couc...@googlegroups.com
If you want to upload a whole directory as a single JSON document using only CURL, I don't think that is possible.
CURL just implements HTTP PUT which deals with individual files.  There is a recursive option, but CURL sends each file as an individual post.
I suppose you could attach each of the files to an existing document, but that does not sound like what you want.

To get a document like couchapp python, erica, kanso, etc. creates, you have to define some rules about nesting and naming and when to encode the contents vs. nesting the text directly.
This would need to be pre-processed before uploading to couchdb as a document.
I would look at how others did it and maybe create a small application to do this work and stream the result to standard output.  Then, you could pipe the output to CURL to get it to couchdb.

Your other options (depending on your environment and use cases) would be to try to create an extension to CouchDB (hard), or put a web app between the client and couchdb to accept individual files or a zip/tarball and combine them into a single document.

If your clients are JavaScript-enabled browsers or mobile apps, you could look at some of the client-side libraries (PouchDB, Couchbase Lite, etc.) and see if they have code for gathering files as JSON documents (I am not familiar with them).

Good luck,
Steve
Reply all
Reply to author
Forward
0 new messages