diff --git a/pom.xml b/pom.xml
index 0122aba..d8c9244 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,7 @@
1.3
v1.4.2
2.7.4
+ 3.13.6
@@ -78,6 +79,11 @@
jackson-databind
${version.jaxon}
+
+ com.konghq
+ unirest-java
+ ${version.unirest}
+
diff --git a/src/main/java/io/ipfs/api/IPFS.java b/src/main/java/io/ipfs/api/IPFS.java
index d022409..6426070 100755
--- a/src/main/java/io/ipfs/api/IPFS.java
+++ b/src/main/java/io/ipfs/api/IPFS.java
@@ -1,21 +1,30 @@
package io.ipfs.api;
-import io.ipfs.cid.*;
-import io.ipfs.multihash.Multihash;
+import io.ipfs.cid.Cid;
import io.ipfs.multiaddr.MultiAddress;
-
-import java.io.*;
-import java.net.*;
-import java.nio.file.*;
+import io.ipfs.multihash.Multihash;
+import kong.unirest.RawResponse;
+import kong.unirest.Unirest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.*;
-import java.util.function.*;
-import java.util.stream.*;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class IPFS {
public static final Version MIN_VERSION = Version.parse("0.4.11");
+
public enum PinType {all, direct, indirect, recursive}
+
public List ObjectTemplates = Arrays.asList("unixfs-dir");
public List ObjectPatchTypes = Arrays.asList("add-link", "rm-link", "set-data", "append-data");
private static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 10_000;
@@ -85,9 +94,10 @@ public IPFS(String host, int port, String version, int connectTimeoutMillis, int
throw new RuntimeException(e);
}
}
-
+
/**
* Configure a HTTP client timeout
+ *
* @param timeout (default 0: infinite timeout)
* @return current IPFS object with configured timeout
*/
@@ -108,14 +118,15 @@ public List add(NamedStreamable file, boolean wrap, boolean hashOnly
}
public List add(List files, boolean wrap, boolean hashOnly) throws IOException {
- Multipart m = new Multipart(protocol + "://" + host + ":" + port + version + "add?stream-channels=true&w="+wrap + "&n="+hashOnly, "UTF-8");
- for (NamedStreamable file: files) {
+ Multipart multipart = new Multipart(protocol + "://" + host + ":" + port + version + "add?stream-channels=true&w=" + wrap + "&n=" + hashOnly, "UTF-8");
+ for (NamedStreamable file : files) {
if (file.isDirectory()) {
- m.addSubtree(Paths.get(""), file);
+ multipart.addSubtree(Paths.get(""), file);
} else
- m.addFilePart("file", Paths.get(""), file);
- };
- String res = m.finish();
+ multipart.addFilePart("file", Paths.get(""), file);
+ }
+
+ String res = multipart.finish();
return JSONParser.parseStream(res).stream()
.map(x -> MerkleNode.fromJSON((Map) x))
.collect(Collectors.toList());
@@ -125,7 +136,7 @@ public List ls(Multihash hash) throws IOException {
Map reply = retrieveMap("ls?arg=" + hash);
return ((List