Class: Gyazo::UploadAdapters::Fog

Inherits:
Object
  • Object
show all
Defined in:
lib/gyazo/upload_adapters/fog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Fog

Returns a new instance of Fog.



8
9
10
# File 'lib/gyazo/upload_adapters/fog.rb', line 8

def initialize(image)
  @image = image
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image.



6
7
8
# File 'lib/gyazo/upload_adapters/fog.rb', line 6

def image
  @image
end

Instance Method Details

#public_urlObject



22
23
24
# File 'lib/gyazo/upload_adapters/fog.rb', line 22

def public_url
  ["http://#{bucket}.s3.amazonaws.com", image.name].compact.join('/')
end

#uploadObject



12
13
14
15
16
17
18
19
20
# File 'lib/gyazo/upload_adapters/fog.rb', line 12

def upload
  connection.put_object(bucket, image.name, image.data,
    {
      'Content-Type' => "image/jpeg",
      'x-amz-acl'    => 'public-read'
    }
  )
  public_url
end