Class: S3::Gyazo::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/s3/gyazo/client.rb

Class Method Summary collapse

Class Method Details

.runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/s3/gyazo/client.rb', line 5

def self.run
  ::Tempfile.create("") do |tmp|
    break unless system "screencapture -x -i \"#{tmp.path}\""
    filename = Time.now.strftime("%Y-%m-%d_%H-%M-%S.png")
    s3 = Aws::S3::Client.new(region: ENV["S3_GAZO_REGION"])
    File.open(tmp.path) do |file|
      s3.put_object(
        bucket: ENV["S3_GAZO_BUCKET"],
        body: file,
        key: filename,
      )
    end
    system "open #{ENV['S3_GAZO_BASE_URL'] + filename}"
  end
end