This commit is contained in:
Jimmy Nguyen 2018-07-01 20:52:48 +00:00 committed by GitHub
commit 4171a251f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,2 @@
#!/bin/zsh
alias filepicker=$ZSH/plugins/filepicker/filepicker.rb

View file

@ -0,0 +1,38 @@
#!/usr/bin/env ruby
require 'rubygems'
# check required gems
['json'].each do |gem|
begin
require gem
rescue LoadError
puts "You need to install #{gem}: gem install #{gem}"
exit!(1)
end
end
# read api key
config_file = "#{ENV['HOME']}/.filepicker"
unless File.exist?(config_file)
puts "You need to type your API key " + config_file
exit!(1)
end
api_key = File.read(config_file)
# checking input file
if ARGV[0].nil?
puts "You need to specify a file to upload."
exit!(1)
end
# upload
file_name = ARGV[0]
json_return = `curl -s -F fileUpload=@#{file_name} 'https://www.filepicker.io/api/store/S3?key=#{api_key}&filename=#{file_name}'`
url = JSON.parse(json_return)['url']
# output to consle the link
puts url
# copy to mac clipboard
`echo #{url} | pbcopy`