如何强制 CouchDB 返回 base64 格式的附件而不是 MIME 多部分/相关的附件?
如 http://wiki.apache.org/couchdb/HTTP_Document_API#Getting_Attachments_With_a_Document 中所述,我可以要求通过以下方式将附件连同文档附件一起退回?attachments=true
。
问题
正如 CouchDB wiki 所说,附件可以以纯 JSON 或 MIME 多部分/相关形式返回。
要获取 MIME 多部分/相关响应格式,只需将“Accept:”标头添加到 请求的值为“multipart/related”。
对我来说,它们总是以 MIME 多部分/相关模式返回,即使没有指定 Accept: 标头也是如此。也许网络浏览器添加了它,但我也无法删除它 - 我需要纯 JSON(用 javascript 处理它们)
问题
我应该怎么做才能获取附件内联,-或者-这是一个 CouchDB 错误吗?
As described in http://wiki.apache.org/couchdb/HTTP_Document_API#Getting_Attachments_With_a_Document , I can ask to return attachments together with the document attachments via ?attachments=true
.
The Problem
As the CouchDB wiki states, attachments can be returned either in plain JSON or MIME multipart/related.
To get MIME multipart/related response format, just add an "Accept:" header to the
request with value "multipart/related".
For me, they are always returned in MIME multipart/related mode, even when no Accept: header is specified. Maybe web browser adds it, but I can't remove it either - and i need plain JSON (to process them with javascript)
The Question
What should I do to get attachments inline, -or- is this a CouchDB bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,Web浏览器会设置
因此,正确的方法是预先重置Accept标头:
By default, the webbrowser sets
So, the correct way is to reset the Accept header beforehand: