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

hjoest/ruby-ipfs-api: Interplanetary File System (IPFS) for Ruby

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

开源软件名称:

hjoest/ruby-ipfs-api

开源软件地址:

https://github.com/hjoest/ruby-ipfs-api

开源编程语言:

Ruby 100.0%

开源软件介绍:

Overview

IPFS-API for Ruby is a client library to access the Interplanetary Filesystem (IPFS) from Ruby.

You can find more examples in the examples directory.

Installation

You need an IPFS daemon running

ipfs daemon

To install this gem, run

gem install ipfs-api

or simply add this line to your Gemfile

gem 'ipfs-api', '~> 0.3.0'

Basic examples

This example will add a directory to IPFS. The directory data must exist or otherwise an Errno::ENOENT error will be raised.

require 'ipfs-api'

ipfs = IPFS::Connection.new
ipfs.add Dir.new('data')

Afterwards, we can retrieve what we put in.

require 'ipfs-api'

ipfs = IPFS::Connection.new

# retrieve contents of a file
print ipfs.cat('QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG')

# retrieve the whole directory and make a copy of it in ``copy-of-data``
ipfs.get('QmSh4Xjoy16v6XmnREE1yCrPM1dnizZc2h6LfrqXsnbBV7', 'copy-of-data')

Advanced

Dynamically add folders and files to IPFS, without creating them on the local file system:

require 'ipfs-api'

ipfs = IPFS::Connection.new
folder = IPFS::Upload.folder('test') do |test|
  test.add_file('hello.txt') do |fd|
    fd.write 'Hello'
  end
  test.add_file('world.txt') do |fd|
    fd.write 'World'
  end
end
ipfs.add folder do |node|
  # display each uploaded node:
  print "#{node.name}: #{node.hash}\n" if node.finished?
end

License

This library is distributed under the MIT License.




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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