Skip to content

Commit 1843eac

Browse files
committed
Updated readme
1 parent 1f9b05b commit 1843eac

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
11
# IPFS-API-Java
2-
A Java implementation of the HTTP IPFS API
2+
A Java implementation of the IPFS http api
33

4+
##Usage
5+
-----
6+
Include the IPFS.jar in your project.
7+
8+
Create an IPFS instance with:
9+
```Java
10+
IPFS ipfs = new IPFS("127.0.0.1", 5001);
11+
```
12+
13+
Then run commands like:
14+
```Java
15+
ipfs.refs.local();
16+
```
17+
18+
To add a file use:
19+
```Java
20+
NamedStreamable.FileWrapper file = new NamedStreamable.FileWrapper(new File("hello.txt"));
21+
MerkleNode addResult = ipfs.add(file);
22+
```
23+
24+
To add a byte[] use:
25+
```Java
26+
NamedStreamable.ByteArrayWrapper file = new NamedStreamable.ByteArrayWrapper("hello.txt", "G'day world! IPFS rocks!".getBytes());
27+
MerkleNode addResult = ipfs.add(file);
28+
```
29+
30+
To get a file use:
31+
```Java
32+
MerkleNode addResult = new MerkleNode("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB");
33+
byte[] fileContents = ipfs.cat(merkleObject);
34+
```
35+
36+
##Building
37+
---------
438
To build just run make. There are no dependencies, just include the resulting IPFS.jar in your project.
39+
40+
To run tests use make tests.

0 commit comments

Comments
 (0)