1
A
回答
2
首先,閱讀CouchDB attachments文檔。
例如:
- 在文件
my_doc
- 要附加文件
hello.html
- 隨着內容
Hello, world
您編碼使用Base64的內容。 "Hello world"
是"'SGVsbG8gd29ybGQ="
。
你創建一個文檔這樣的:
{ "_id": "my_doc",
, "_attachments":
{ "hello.html":
{ "content_type": "text/html"
, "data": "'SGVsbG8gd29ybGQ="
}
}
}
唯一困難的部分是base64編碼。我建議你使用CouchDB內包含的base64腳本。
<html>
<head>
<script src="/_utils/script/base64.js"></script>
</head>
<body>
The Base64 of "Hello world" is:
<script>
var hello = "Hello world"
var encoded = Base64.encode(hello)
document.write(encoded)
</script>
<p>
A document with this attachment is:<br>
<script>
var doc = { "_id":"my_doc" }
doc._attachments = {}
doc._attachments["hello.html"] = {}
doc._attachments["hello.html"].content_type = "text/html"
doc._attachments["hello.html"].data = Base64.encode("Hello world")
document.write(JSON.stringify(doc))
</script>
</body>
</html>
相關問題
- 1. 使用ecouch在Couchdb中存儲獨立附件庫
- 2. Couchdb如何存儲重複的附件?
- 3. 使用內聯附件
- 4. 如何使用Java將Blob存儲在CouchDB中?
- 5. 保存Excel文件使用Java腳本
- 6. Javascript - 腳本內存vs DOM存儲
- 7. Bash腳本使用mailx郵件附件
- 8. 附件中的CouchDB snappy
- 9. 使用web2py流式傳輸couchdb附件
- 10. Couchdb多個附件
- 11. 在「大」文件創建中降低腳本內存使用率
- 12. 如何在內部聯接中使用存儲過程?
- 13. Java腳本存儲和加載狀態
- 14. 使用PouchDB時,是否存在本地存儲的所有關聯的遠程CouchDB數據庫?
- 15. 如何使用更新功能上傳附件在CouchDB中
- 16. 什麼是在CouchDB附件中使用的「revpos」值?
- 17. 在CouchDB與MySQL中存儲調查
- 18. 無法在CouchDB中存儲推文
- 19. 使用sqlcmd執行腳本文件中存儲的proc -i
- 20. 存儲對運行時附加的腳本的引用
- 21. 如何使用Elasticsearch和Tire防止附件存儲在_source中?
- 22. 如何使用java腳本調用存在於ALM中的uft腳本?
- 23. 內聯腳本將多個值附加到url問題
- 24. 腳本文件在內聯腳本中執行後使用CDN或外部域在HTML注入
- 25. ROR中的內聯附件2.3.8
- 26. 運行存儲在互聯網上的Ruby腳本
- 27. 什麼是內聯腳本?
- 28. 內聯bash腳本變量
- 29. Bash腳本 - 在變量中存儲stderr
- 30. 閱讀整個XML文件並存儲在內存中java