Class: Ipfs::Commands::CatToFile

Inherits:
Base
  • Object
show all
Defined in:
lib/ipfs-http-client-rb/commands/cat_to_file.rb

Class Method Summary collapse

Methods inherited from Base

parse, request

Class Method Details

.call(client, node, path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ipfs-http-client-rb/commands/cat_to_file.rb', line 6

def self.call(client, node, path)
  response = request(client, "/cat?arg=#{node}")

  begin
    file = File.open(path, 'wb')
    while (chunk = response.body.readpartial)
      file.write chunk
    end
  ensure
    file.close if file
  end

  true
end