A Java implementation of the UDFS http api
You can use this project by including ipfs.jar
from one of the releases.
Package managers are supported through JitPack which supports Maven, Gradle, SBT, etc.
for Maven, add the following sections to your pom.xml (replacing $LATEST_VERSION):
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.UlordChain</groupId>
<artifactId>java-udfs-api</artifactId>
<version>v1.1</version>
</dependency>
Create an UDFS instance with:
http: UDFS udfs = new UDFS("127.0.0.1",5001,false);
https: UDFS udfs = new UDFS("127.0.0.1",5001,true);
Then run commands like:
udfs.refs.local();
To add a file and bakeup other masternode use (the push method returns a list of merklenodes, in this case there is only one element):
NamedStreamable.FileWrapper file = new NamedStreamable.FileWrapper(new File("udfs.txt"));
MerkleNode addResult = udfs.push(file).get(0);
To push a byte[] use:
NamedStreamable.ByteArrayWrapper file = new NamedStreamable.ByteArrayWrapper("udfs.txt", "hello world".getBytes());
MerkleNode addResult = udfs.push(file).get(0);
To get a file use:
Multihash filePointer = Multihash.fromBase58("hash值");
byte[] fileContents = udfs.cat(filePointer);
Current versions of dependencies are included in the ./lib
directory.