lib/skynet/download.rb
# Download file from the skynet portal
# file_name & skylink is required, the rest is optional since they come with default values
Download file from the skynet portal
file_name & skylink is required, the rest is optional since they come with default values
Download file from the skynet portal file_name & skylink is required the rest is optional since they come with default values
def download_file(file_name, skylink, override_options = {}, stream: true)
    options = Helper::Download.default_options
    options = Helper::Download.default_options.merge(override_options) unless override_options.empty?
    portal  = options[:portal_url]
    skylink = Helper::Download.strip_prefix(skylink)
    url = "#{portal}#{skylink}?attachment=#{options[:download]}"
    File.open(file_name, 'w') do |file|
      HTTParty.get(url, follow_redirects: true, stream_body: stream) do |chunk|
        file << chunk unless HTTP_REDIRECT_PERMANENT.include? chunk.code
      end
    end
    'Download successful!'
  end
def download_file ( file_name , skylink , override_options = { } , stream : true ) options = Helper :: Download . default_options options = Helper :: Download . default_options . merge ( override_options ) unless override_options . empty? portal = options [ :portal_url ] skylink = Helper :: Download . strip_prefix ( skylink ) url = "#{portal}#{skylink}?attachment=#{options[:download]}" File . open ( file_name , 'w' ) do | file | HTTParty . get ( url , follow_redirects : true , stream_body : stream ) do | chunk | file << chunk unless HTTP_REDIRECT_PERMANENT . include? chunk . code end end 'Download successful!' end
Download file from the skynet portal
file_name & skylink is required, the rest is optional since they come with default values
Download file from the skynet portal file_name & skylink is required the rest is optional since they come with default values
file_name
skylink
override_options
stream