33 lines
927 B
Ruby
Executable File
33 lines
927 B
Ruby
Executable File
#!env ruby
|
|
require 'rubygems'
|
|
require 'digest/md5'
|
|
require 'net/scp'
|
|
require 'open-uri'
|
|
require 'ruby-progressbar'
|
|
|
|
files = []
|
|
|
|
Net::SCP.start("i.am-a.cat", "arachnist") do |scp|
|
|
ARGV.each do |path|
|
|
ext = "." + path.sub(/.*[.]([^.]*)/, '\1') if path.match(/[^.]+[.][^.]+/)
|
|
content = open(path).read
|
|
files << {
|
|
:title => path.sub(/.*\//, ''),
|
|
:ext => ext,
|
|
:md5 => Digest::MD5.hexdigest(content),
|
|
:content => content,
|
|
:size => content.bytes.count
|
|
}
|
|
end
|
|
|
|
files.each do |f|
|
|
p = ProgressBar.create(:title => f[:title], :total => f[:size], :format => '%t | %E | %w>')
|
|
|
|
scp.upload! StringIO.new(f[:content]), "/home/arachnist/public_html/c/#{f[:md5]}#{f[:ext]}" do |ch, name, sent, total|
|
|
p.progress = sent
|
|
end
|
|
|
|
puts "\t=> https://arachnist.is-a.cat/c/#{f[:md5]}#{f[:ext]}"
|
|
end
|
|
end
|