• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ipfs-shipyard/scala-ipfs-api: A wrapper of the IPFS Client HTTP-API for Scala.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ipfs-shipyard/scala-ipfs-api

开源软件地址:

https://github.com/ipfs-shipyard/scala-ipfs-api

开源编程语言:

Scala 94.2%

开源软件介绍:

scala-ipfs-api

standard-readme compliant

A wrapper of the IPFS Client HTTP-API for Scala.

A JVM client library for interacting with IPFS from Java/Scala environments.

Documentation

A full java-doc site is available here.

Including in your Java/Scala project

SBT:
resolvers += "scala-ipfs-api" at "https://ipfs.io/ipfs/QmbWUQEuTtFwNNg94nbpVY25b5PAyPQTd7HhkDsGhRG8Ur/"
libraryDependencies += "io.ipfs" %% "scala-ipfs-api" % "1.0.0-SNAPSHOT",
Manually:

Although this is considered a bad practice, you may still want to manually put fat-jar generated from assembly task into your classpath, take a look at stand-alone jar creation below.

Java usage

A working Java example available here.

IPFS API calls are available using a Client instance.

Client client = new Client("localhost", 5001, "/api/v0", "http");

Almost all of the API calls return strongly typed POJOs, for example the node configuration can be retrieved with

ConfigShow configShow = client.configShow();

Adding and retrieving data
        //create test file
        Path addPath = Paths.get("ipfs.put.tmp.txt");
        Files.write(addPath, "Hello IPFS!".getBytes(), StandardOpenOption.CREATE);

        //add to IPFS
        Add[] add = client.add(new Path[]{addPath});
        Add added = add[0];
        System.out.println("Added "+ added.Name() +" with hash "+  added.Hash());

        //get from IPFS
        Path getPath = Paths.get("ipfs.get.tmp.txt");
        try (InputStream inputStream = client.cat(added.Hash())) {
            Files.copy(inputStream, getPath, StandardCopyOption.REPLACE_EXISTING);
        }

Building

The package can be built using sbt.

compiling

Compile the project with

sbt compile

package sources only

To build a Java archive, use

sbt packageBin

which will create a jar like target/scala-2.10/scala-ipfs-api_2.10-1.0.0-SNAPSHOT.jar

stand-alone jar

To create a stand-alone jar that includes all dependencies, do

sbt assembly

which will create a jar

target/scala-2.10/ipfs.api.jar

Testing

Unit / Integration tests can be run with

sbt test

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap