Last active
August 29, 2015 14:24
-
-
Save winebarrel/7e6a4c470fa7b904cbe8 to your computer and use it in GitHub Desktop.
Replace "Gyazo/script" to follow script:
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 | |
require 'securerandom' | |
require 'tmpdir' | |
S3_BACKET = 'my-bucket' | |
S3_PATH = 'path' | |
ENDPOINT = 'my-bucket.s3-website-ap-northeast-1.amazonaws.com' | |
Dir.mktmpdir do |dir| | |
now = Time.now.utc | |
filename = "#{now.to_i}.#{SecureRandom.uuid}.png" | |
tmpfile = File.join(dir, filename) | |
path = File.join(S3_PATH, now.strftime('%Y/%m/%d'), filename) | |
upload_path = File.join(S3_BACKET, path) | |
system(%!screencapture -i "#{tmpfile}"!) | |
system(%!sips -d profile --deleteColorManagementProperties "#{tmpfile}"!) | |
system(%!/usr/local/bin/aws s3 cp "#{tmpfile}" s3://#{upload_path}!) | |
#system(%!osascript -e 'display notification "s3://#{upload_path}" with title "Gyazo"'!) | |
system(%!open http://#{File.join(ENDPOINT, path)}!) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment