Class: Ipfs::Commands::CatToFile

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

Class Method Summary collapse

Methods inherited from Base

http_get, parse

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/commands/cat_to_file.rb', line 6

def self.call(client, node, path)
  http_get(client, "/cat?arg=#{node}") do |response|
    begin
      file = File.open(path, 'wb')
      while (chunk = response.body.readpartial)
        file.write chunk
      end
    ensure
      file.close if file
    end
  end

  true
end