Class: Cognac::CloudFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cognac/cloud_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ CloudFile

Returns a new instance of CloudFile.



6
7
8
# File 'lib/cognac/cloud_file.rb', line 6

def initialize(file_name)
  @file_name = file_name
end

Instance Method Details

#nameObject

To avoid file collision, we prepend random string to the file_name



11
12
13
# File 'lib/cognac/cloud_file.rb', line 11

def name
  "#{SecureRandom.hex(4).to_s}_#{@file_name}"
end

#resource_end_pointObject



15
16
17
18
# File 'lib/cognac/cloud_file.rb', line 15

def resource_end_point
  raise 'AWS_S3_BUCKET Environment variable is not intialized. Refer README.md at https://bitbucket.org/bparanj/cognac' if Cognac.aws_s3_bucket.nil?
  "http://#{Cognac.aws_s3_bucket}.s3.amazonaws.com/#{name}"
end