Skip to content

UlordChain/java-udfs-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-udfs-api

A Java implementation of the UDFS http api

Table of Contents

Install

Official releases

You can use this project by including ipfs.jar from one of the releases.

Maven, Gradle, SBT

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.1</version>
    </dependency>

Usage

environment configuration:

testnet environment:
url=http://test.api.udfs.one:15001
formal environment:
url=http://api.udfs.one:15001

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):

String filePath = "C:\\Users\\Allen\\Desktop\\certificate\\1.png";
        String url="http://test.api.udfs.one:15001/api/v0/add";
        String type="add";
        UdfsDevTools tools = new UdfsDevTools(1000, "", "", filePath, "");
        File file = new File(filePath);
        String Result = UdfsDevTools.FilePost(url, file,tools.getToken(type));
        System.out.println("Result:"+Result);

To push a byte[] use:

String filePath = "C:\\Users\\Allen\\Desktop\\certificate\\1.png";
        String url="http://test.api.udfs.one:15001/api/v0/push";
        String type="add";
        UdfsDevTools tools = new UdfsDevTools(1000, "", "", filePath, "");
        File file = new File(filePath);
        String Result = UdfsDevTools.FilePost(url, file,tools.getToken(type));
        System.out.println("Result:"+Result);

To get a file use:

String hash="";
        String url="http://test.api.udfs.one:15001/api/v0/cat/"+hash;
        String type="get";
        UdfsDevTools tools = new UdfsDevTools(100, "", "", "");
        System.out.println(tools.getToken(type));
        UdfsDevTools.download(url, "微信图片_20181113205946.jpg","F:\\分布式存储\\",tools.getToken(type));

Dependencies

Current versions of dependencies are included in the ./lib directory.