File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,16 @@ public List<MerkleNode> put(List<byte[]> data) throws IOException {
169
169
return JSONParser .parseStream (res ).stream ().map (x -> MerkleNode .fromJSON ((Map <String , Object >) x )).collect (Collectors .toList ());
170
170
}
171
171
172
+ public List <MerkleNode > put (String encoding , List <byte []> data ) throws IOException {
173
+ if (!"json" .equals (encoding ) && "protobuf" .equals (encoding ))
174
+ throw new IllegalArgumentException ("Encoding must be json or protobuf" );
175
+ Multipart m = new Multipart ("http://" + host + ":" + port + version +"object/put?stream-channels=true&encoding=" +encoding , "UTF-8" );
176
+ for (byte [] f : data )
177
+ m .addFilePart ("file" , new NamedStreamable .ByteArrayWrapper (f ));
178
+ String res = m .finish ();
179
+ return JSONParser .parseStream (res ).stream ().map (x -> MerkleNode .fromJSON ((Map <String , Object >) x )).collect (Collectors .toList ());
180
+ }
181
+
172
182
public MerkleNode get (Multihash hash ) throws IOException {
173
183
Map json = retrieveMap ("object/get?stream-channels=true&arg=" + hash );
174
184
json .put ("Hash" , hash .toBase58 ());
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ public void objectTest() {
101
101
Multihash pointer = Multihash .fromBase58 ("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB" );
102
102
MerkleNode object = ipfs .object .get (pointer );
103
103
List <MerkleNode > newPointer = ipfs .object .put (Arrays .asList (object .toJSONString ().getBytes ()));
104
+ List <MerkleNode > newPointer2 = ipfs .object .put ("json" , Arrays .asList (object .toJSONString ().getBytes ()));
104
105
MerkleNode links = ipfs .object .links (pointer );
105
106
byte [] data = ipfs .object .data (pointer );
106
107
Map stat = ipfs .object .stat (pointer );
You can’t perform that action at this time.
0 commit comments