Sha256: 02ec0f11ffc447848f4250b67acd3106961baac34e22d5b5ff54867a7c297cde
Contents?: true
Size: 660 Bytes
Versions: 2
Compression:
Stored size: 660 Bytes
Contents
require "net/sftp" module Anyfetch class SFTP def initialize(uri, options = {}) @uri = uri @options = options end def open user = @options.delete(:user) || @uri.user options = { password: @uri.password }.merge(@options) filename = ::File.basename(@uri.path) tempfile = Tempfile.new(filename) tempfile.binmode Net::SFTP.start(@uri.host, user, options) do |sftp| sftp.file.open(@uri.path, "r") do |file| while !file.eof? do tempfile << file.read(32 * 1024 * 1024) end end end tempfile.extend(OriginalFilename::Path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
anyfetch-0.1.7 | lib/anyfetch/sftp.rb |
anyfetch-0.1.6 | lib/anyfetch/sftp.rb |