【问题标题】:How to create attachments in couchDB using RestAPI java client如何使用 Rest API java 客户端在 couchDB 中创建附件
【发布时间】:2018-05-23 19:40:45
【问题描述】:

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

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

谢谢

【问题讨论】:

    标签: azure nosql couchdb bitnami


    【解决方案1】:

    如果你使用LightCouchJava 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-24
      • 2021-10-14
      • 1970-01-01
      • 1970-01-01
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多