Created
May 24, 2016 12:31
-
-
Save Nephos/f38388f446426bb940b14bbe6b63a79b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Note: this code works also in crystal :) | |
# Just replace the shebang "ruby" by "crystal" or build it | |
require "tempfile" | |
require "uri" | |
uploader = ENV.fetch("TRANSFER_HOST") { "https://up.nephos.xyz" } | |
base = File.basename(ARGV[0]) | |
ext = File.extname(ARGV[0]) | |
min = base[0..4] + ext | |
uri = URI.parse(uploader + "/" + min).to_s | |
Tempfile.open("transfer-") do |f| | |
#curl --progress-bar --upload-file $1 https://transfer.sh/$(basename $1) >> $tmpfile | |
`curl --progress-bar --upload-file #{ARGV[0]} #{uri} >> #{f.path}` | |
puts f.gets | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment