Module: EasyS3

Defined in:
lib/easy_s3.rb,
lib/easy_s3/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.append(path, data) ⇒ Object



13
14
15
16
# File 'lib/easy_s3.rb', line 13

def self.append(path, data)
  # appends data to the value of the file
  self.write(path, self.read(path) + data)
end

.exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/easy_s3.rb', line 25

def self.exists?(path)
  # returns true or false depending on whether the file exists
  AWS::S3::S3Object.exists?(path, S3_BUCKET)
end

.file(path) ⇒ Object



21
22
23
24
# File 'lib/easy_s3.rb', line 21

def self.file(path)
  # retuns the actual file object, use .value to get the contents
  AWS::S3::S3Object.find(path, S3_BUCKET)
end

.read(path) ⇒ Object



17
18
19
20
# File 'lib/easy_s3.rb', line 17

def self.read(path)
  # retuns the actual value of the file, use EasyS3.get_file if you want the object
  self.file(path).value
end

.write(path, data) ⇒ Object



9
10
11
12
# File 'lib/easy_s3.rb', line 9

def self.write(path, data)
  # creates a new file or overwrites an existing file with data
  AWS::S3::S3Object.store(path, data, S3_BUCKET, :access => :public_read)
end