Module: IPFS::Upload

Defined in:
lib/ipfs-api/upload.rb

Defined Under Namespace

Modules: TreeWalker Classes: FileNode, FolderNode, Node

Class Method Summary collapse

Class Method Details

.file(name, content = nil, &block) ⇒ Object

Define a file with the given name.

file = IPFS::Upload.file('hello.txt') do |fd|
  fd.write 'Hello'
end
ipfs.add file do |node|
  print "Successfully uploaded #{node.path}\n" if node.finished?
end


12
13
14
# File 'lib/ipfs-api/upload.rb', line 12

def file name, content = nil, &block
  FileNode.new(name, content, &block)
end

.folder(name, &block) ⇒ Object

Define a folder with the given name.

folder = IPFS::Upload.folder('test') do |test|
  test.add_file('hello.txt') do |fd|
    fd.write 'Hello'
  end
end
ipfs.add folder do |node|
  print "Successfully uploaded #{node.path}\n" if node.finished?
end


26
27
28
# File 'lib/ipfs-api/upload.rb', line 26

def folder name, &block
  FolderNode.new(name, &block)
end