class Ipfs::Commands::CatToFile

Public Class Methods

call(client, node, path) click to toggle source
# 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