Skip to content

Instantly share code, notes, and snippets.

@Nephos
Created May 24, 2016 12:31
Show Gist options
  • Save Nephos/f38388f446426bb940b14bbe6b63a79b to your computer and use it in GitHub Desktop.
Save Nephos/f38388f446426bb940b14bbe6b63a79b to your computer and use it in GitHub Desktop.
#!/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