gpt4 book ai didi

azure - 如何使用 Rest API java 客户端在 couchDB 中创建附件

转载 作者:行者123 更新时间:2023-12-03 04:19:24 25 4
gpt4 key购买 nike

我需要在 CouchDB 上存储附件。我将如何使用 Java 来做到这一点。我可以使用哪些 API?有我可以引用的示例代码或文档吗?目前我们正在使用 cloudantdb,但我们计划在 Azure 上使用 CouchDB

com.cloudant.client.api.Database;com.cloudant.client.api.model.Response;

谢谢

最佳答案

如果您使用LightCouch Java API

InputStream in =  // .. init stream

// save under a new document, a generated UUID is assigned as id.
Response response = dbClient.saveAttachment(in, "photo.png", "image/png");

// save to an existing document
dbClient.saveAttachment(in, "file.pdf", "application/pdf", "doc-id", "doc-rev");

// save under a new document with the given id.
dbClient.saveAttachment(in, "photo.jpeg", "image/jpeg", "doc-id", null);

// get attachment
InputStream in = dbClient.find("doc-id/photo.jpeg");
// ..
in.close(); // close the stream

关于azure - 如何使用 Rest API java 客户端在 couchDB 中创建附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50496285/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com