4
我正在使用CouchApp構建一個允許上傳和管理圖片的簡單Web應用程序。實際的圖像文件存儲爲文檔的附件,如下所示。獲取附件的url
{
"_id":"09fe82d75a26f9aa5e722d6b220180d2",
"_rev":"2-5797b822c83b9d41545139caa592f611",
"data":"some additional fields with info about the image",
"_attachments":
{
"foo.jpg":
{
"stub":true,
"content_type":"image/jpeg",
"length":23721
}
}
}
但爲了在html中集成圖像,我需要URL到附件。 我如何得到這個網址?
我使用evently和小鬍子來生成網頁。下面是data.js讀取數據:
function(data) {
return {
items : data.rows.map(function(r) {
return {
id : r.value._id,
rev : r.value._rev,
title : r.value.description,
url : "how am i supposed to do this?"
};
})
};
};
你看過這個http://wiki.apache.org/couchdb/HTTP_Document_API#Attachments嗎? –