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

zabirauf/elixir-ipfs-api: The Elixir library that is used to communicate with th ...

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

开源软件名称:

zabirauf/elixir-ipfs-api

开源软件地址:

https://github.com/zabirauf/elixir-ipfs-api

开源编程语言:

Elixir 100.0%

开源软件介绍:

Build Status Inline docs

Current Version: v0.1.0

Elixir-Ipfs-Api

The Elixir library that is used to communicate with the IPFS REST endpoint.

elixir_ipfs_api

Documentation

The documentation is posted at hexdocs

How to use it

1. Add the library to mix.exs

The package is published on Hex. Add the elixir_ipfs_api as follow

defp deps do
    [
        ...
        {:elixir_ipfs_api, "~> 0.1.0"}
        ...
    ]
end

2. Start the IPFS Daemon

Start the IPFS daemon by running the following in terminal

$ ipfs daemon

This will start the ipfs daemon with the API endpoint at localhost:5001. If you want to start the API endpoint at a different address then add to the config

$ ipfs config Addresses.API /ipfs/127.0.0.1/tcp/5007

3. Create the IpfsConnection in your code

The IpfsConnection entity contains the information of the IPFS API endpoint. By default it will try to connect to http://localhost:5001/api/v0

conn = %IpfsConnection{host: "127.0.0.1", base: "api/v0", port: 5007}

Examples

Adding content to IPFS

iex> conn = %IpfsConnection{}
iex> IpfsApi.add(conn, "Hello world from Elixir-Ipfs-Api")
{:ok,
 %{"Hash" => "QmTcCZJEW1kUcYU1bKQk9SMGRsTisMMWXuxJ1AQerHwyaA",
 "Name" => "QmTcCZJEW1kUcYU1bKQk9SMGRsTisMMWXuxJ1AQerHwyaA"}}

Getting content from IPFS

iex> conn = %IpfsConnection{}
iex> IpfsApi.get(conn, "QmTcCZJEW1kUcYU1bKQk9SMGRsTisMMWXuxJ1AQerHwyaA")
<<81, 109, 84, 99, 67, 90, 74, 69, 87, 49, 107, 85, 99, 89, 85, 49, 98, 75, 81, 107, 57, 83, 77, 71, 82, 115, 84, 105, 115, 77, 77, 87, 88, 117, 120, 74, 49, 65, 81, 101, 114, 72, 119, 121, 97, 65, 0, 0, 0, 0, ...>>

TODO

  • [] Add stream for adding & getting files to and from IPFS
  • [] Add a pool to request from multiple different IPFS nodes



鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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