incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Attachment serving, directories
Date Sun, 21 Mar 2010 08:06:47 GMT

On 20 Mar 2010, at 23:01, 7zark7 wrote:

> Let me rephrase the question:
> 
> Are there any CouchDB 0.10 mechanisms (views, show function, etc) which allows me to
serve a binary attachment that has one or more '/' characters in the requested file id?

Yes :)

> echo $COUCH
http://127.0.0.1:5984
> curl -X PUT $COUCH/x
{"ok":true}
> curl -X PUT $COUCH/x/a -d '{"a":1}'
{"ok":true,"id":"a","rev":"1-23202479633c2b380f79507a776743d5"}
> curl -X PUT $COUCH/x/a/att/ach.txt?rev=1-23202479633c2b380f79507a776743d5 -d 'hello'
{"ok":true,"id":"a","rev":"2-04854b6987edbce4e4b3f07dd9b1caa5"}
> curl -X GET $COUCH/x/a
{"_id":"a","_rev":"2-04854b6987edbce4e4b3f07dd9b1caa5","a":1,"_attachments":{"att/ach.txt":{"content_type":"application/octet-stream","revpos":2,"length":0,"stub":true}}}
curl -X GET $COUCH/x/a/att/ach.txt
hello


Cheers
Jan
--

> 
> I do not care about the url prefix or its length. In other words, these prefixes are
all acceptable:
> 
> http://example.com:5984/some_db/{my file path here}
> http://example.com:5984/some_db/_design/file/_show/{my file path here}
> etc
> 
> What I do care about is that a browser can directly request a binary file such as "/scripts/main/common.js",
without our having to go into hundreds of HTML files to rename these file references to "%2Fscripts%2Fmain%2Fcommon.js".
 Nor do I want an app server or Apache in place simply to do a file name translation.
> 
> 
> The specific value proposition that CouchDB offers in this case is that it replaces:
> 
> 1) Content distribution to multiple nodes in our network.
> 2) Replaces an app server/Apache serving static content.
> 3) It is highly concurrent.
> 
> Does anyone have experience doing the above or similar?
> 
> I can write a blog post if email is not conveying my question correctly.
> 
> 
> Thanks
> 
> 
> On 3/20/10 7:22 PM, John Merrells wrote:
>> 
>> On Mar 20, 2010, at 4:44 PM, 7zark7 wrote:
>> 
>>>> I do not want to have another webapp "in front" of Couch to translate a
>>>> request for "/scripts/main.js" into "%2fscripts%2fmain.js/data", or
>>>> "/a1b0e2349f53456/scripts/main.js", etc.
>> 
>> How about serving the static content directly from the disk with a webserver
>> like apache or nginx....
>> 
>> If you really want the content in couch, then you could do the url rewrite with
>> some rules in the webserver config...
>> 
>> Or use a reverse proxy like varnish.... or squid if you're feeling brave.... and
>> then the content could be in couch for versioning, but served fast from the
>> cache.
>> 
>> John
>> 
> 


Mime
View raw message