lightcouch / LightCouch

CouchDB Java API
www.lightcouch.org
Apache License 2.0
67 stars 70 forks source link

Add a method removeAttachment #81

Open holgerengels opened 2 years ago

holgerengels commented 2 years ago

Hi, could you please add this method to CouchDbClientBase.java

Index: src/main/java/org/lightcouch/CouchDbClientBase.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/org/lightcouch/CouchDbClientBase.java b/src/main/java/org/lightcouch/CouchDbClientBase.java
--- a/src/main/java/org/lightcouch/CouchDbClientBase.java   (revision c65454f7851681f527d791ac6eefd221c914a06a)
+++ b/src/main/java/org/lightcouch/CouchDbClientBase.java   (revision 44b99c82255cee5a8c6fd959693f2919e64b185e)
@@ -507,6 +507,22 @@
         return put(uri, in, contentType);
     }

+    /**
+     * removes an attachment from an existing document given a document id and revision and the attachment name
+     *
+     * @param name The attachment name.
+     * @param docId The document id to remove the attachment from
+     * @param docRev The document revision to remove the attachment from
+     * @return {@link Response}
+     */
+    public Response removeAttachment(String name, String docId, String docRev) {
+        assertNotEmpty(name, "name");
+        assertNotEmpty(docId, "docId");
+        assertNotEmpty(docRev, "docRev");
+        final URI uri = buildUri(getDBUri()).pathEncoded(docId).path("/").path(name).query("rev", docRev).build();
+        return delete(uri);
+    }
+
     /**
      * Invokes an Update Handler.
      *