azure - 如何使用 RestAPI java 客户端在 couchDB 中创建附件
问题描述
我需要在 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
推荐阅读
- c - 迭代大小为 100000 的 C char 数组需要大量时间
- java - 将对象数组输入对象的 Arraylist 并更改属性
- ruby-on-rails - 使用 Ruby Geocoder gem 创建 Location 对象
- excel - 如果区域中只有一个单元格具有值,则将单元格区域中的值复制到另一个单元格
- python - 在具有交互项的 logit 模型中使用 statsmodels 的 get_margeff 命令计算 Python 中的边际效应
- python-3.x - 如何使用锁或其他方法暂停异步创建的任务?
- python - vscode从子目录激活主目录中的虚拟环境
- php - 通过 PHP 上传到 AWS S3 时拒绝访问;但它通过 CLI 工作
- java - java.lang.IllegalArgumentException:指定为非空的参数为空:- android,应用程序启动但立即崩溃
- xamarin.forms - Xamarin 在服装视图之上渲染子视图