code: public Response saveAttachment(InputStream in, String name, String contentType, String docId,
                                     String docRev) {
          assertNotEmpty(in, "in");
          assertNotEmpty(name, "name");
          assertNotEmpty(contentType, "ContentType");
          if (docId == null) {
              docId = generateUUID();
              // A new doc is being created; there should be no revision specified.
              assertNull(docRev, "docRev");
          } else {
              // The id has been specified, ensure it is not empty
              assertNotEmpty(docId, "docId");
              if (docRev != null) {
                  // Existing doc with the specified ID, ensure rev is not empty
                  assertNotEmpty(docRev, "docRev");
              }
          }
          final URI uri = new DatabaseURIHelper(dbUri).attachmentUri(docId, docRev, name);
          return couchDbClient.put(uri, in, contentType);
      }
docs: Saves an attachment to an existing document given both a document id
  and revision, or save to a new document given only the id, and rev as {@code null}.
  <p>To retrieve an attachment, see {@link #find(String)}.
  
  @param in          The {@link InputStream} holding the binary data.
  @param name        The attachment name.
  @param contentType The attachment "Content-Type".
  @param docId       The document id to save the attachment under, or {@code null} to save
  under a new document.
  @param docRev      The document revision to save the attachment under, or {@code null}
  when saving to a new document.
  @return {@link Response}
  @throws DocumentConflictException