@@ -40,7 +40,7 @@ public enum PinType {all, direct, indirect, recursive}
40
40
public final Stats stats = new Stats ();
41
41
public final Name name = new Name ();
42
42
public final Pubsub pubsub = new Pubsub ();
43
-
43
+
44
44
public IPFS (String host , int port ) {
45
45
this (host , port , "/api/v0/" , false );
46
46
}
@@ -56,13 +56,13 @@ public IPFS(MultiAddress addr) {
56
56
public IPFS (String host , int port , String version , boolean ssl ) {
57
57
this .host = host ;
58
58
this .port = port ;
59
-
59
+
60
60
if (ssl ) {
61
61
this .protocol = "https" ;
62
62
} else {
63
63
this .protocol = "http" ;
64
64
}
65
-
65
+
66
66
this .version = version ;
67
67
// Check IPFS is sufficiently recent
68
68
try {
@@ -73,7 +73,7 @@ public IPFS(String host, int port, String version, boolean ssl) {
73
73
throw new RuntimeException (e );
74
74
}
75
75
}
76
-
76
+
77
77
public List <MerkleNode > add (NamedStreamable file ) throws IOException {
78
78
return add (file , false );
79
79
}
@@ -493,7 +493,7 @@ public Map disconnect(String multiAddr) throws IOException {
493
493
494
494
public class Dag {
495
495
public byte [] get (Cid cid ) throws IOException {
496
- return retrieve ("block /get?stream-channels=true&arg=" + cid );
496
+ return retrieve ("dag /get?stream-channels=true&arg=" + cid );
497
497
}
498
498
499
499
public MerkleNode put (byte [] object ) throws IOException {
@@ -509,9 +509,8 @@ public MerkleNode put(byte[] object, String outputFormat) throws IOException {
509
509
}
510
510
511
511
public MerkleNode put (String inputFormat , byte [] object , String outputFormat ) throws IOException {
512
- block .put (Arrays .asList (object ));
513
- String prefix = protocol +"://" + host + ":" + port + version ;
514
- Multipart m = new Multipart (prefix + "block/put/?stream-channels=true&input-enc=" + inputFormat + "&f=" + outputFormat , "UTF-8" );
512
+ String prefix = protocol + "://" + host + ":" + port + version ;
513
+ Multipart m = new Multipart (prefix + "dag/put/?stream-channels=true&input-enc=" + inputFormat + "&f=" + outputFormat , "UTF-8" );
515
514
m .addFilePart ("file" , Paths .get ("" ), new NamedStreamable .ByteArrayWrapper (object ));
516
515
String res = m .finish ();
517
516
return MerkleNode .fromJSON (JSONParser .parse (res ));
@@ -724,7 +723,7 @@ private static final byte[] readFully(InputStream in) throws IOException {
724
723
resp .write (buf , 0 , r );
725
724
return resp .toByteArray ();
726
725
}
727
-
726
+
728
727
private static boolean detectSSL (MultiAddress multiaddress ) {
729
728
return multiaddress .toString ().contains ("/https" );
730
729
}
0 commit comments