Class: Capriza::AWS::S3File
- Inherits:
-
Object
- Object
- Capriza::AWS::S3File
- Defined in:
- lib/capriza-aws-helper.rb
Instance Method Summary collapse
- #<=>(local_file) ⇒ Object
- #download ⇒ Object
- #exists? ⇒ Boolean
- #get_metadata(key) ⇒ Object
-
#initialize(bucket, file_name, config) ⇒ S3File
constructor
A new instance of S3File.
- #set_metadata(key, value) ⇒ Object
- #upload(data, make_public = false, content_type = 'application/zip') ⇒ Object
Constructor Details
Instance Method Details
#<=>(local_file) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/capriza-aws-helper.rb', line 82 def <=> (local_file) unless File.exist?(local_file) raise "File #{local_file} does not exist" end @obj.etag.gsub(/\"/, "") == Digest::MD5.hexdigest(File.read(local_file)) end |
#download ⇒ Object
66 67 68 |
# File 'lib/capriza-aws-helper.rb', line 66 def download @data = @obj.read end |
#exists? ⇒ Boolean
70 71 72 |
# File 'lib/capriza-aws-helper.rb', line 70 def exists? @obj.exists? end |
#get_metadata(key) ⇒ Object
78 79 80 |
# File 'lib/capriza-aws-helper.rb', line 78 def (key) @obj.[key] end |
#set_metadata(key, value) ⇒ Object
74 75 76 |
# File 'lib/capriza-aws-helper.rb', line 74 def (key, value) @obj.[key] = value end |
#upload(data, make_public = false, content_type = 'application/zip') ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/capriza-aws-helper.rb', line 58 def upload(data, make_public = false, content_type = 'application/zip') @data = data @obj.write(@data) = @obj.head[:metadata] @obj.copy_to(@obj.key, :metadata => , :content_type => content_type) @obj.acl = :public_read if make_public end |