Class: S3Archive::S3File
- Inherits:
-
Struct
- Object
- Struct
- S3Archive::S3File
- Includes:
- Logging
- Defined in:
- lib/s3archive/s3_file_synchronizer.rb
Overview
A wrapper around a s3 path (bucket, key) with some md5 and a put function
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
Methods included from Logging
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket
64 65 66 |
# File 'lib/s3archive/s3_file_synchronizer.rb', line 64 def bucket @bucket end |
#key ⇒ Object
Returns the value of attribute key
64 65 66 |
# File 'lib/s3archive/s3_file_synchronizer.rb', line 64 def key @key end |
Instance Method Details
#exists? ⇒ Boolean
71 72 73 |
# File 'lib/s3archive/s3_file_synchronizer.rb', line 71 def exists? !headers.nil? end |
#md5_hex ⇒ Object
67 68 69 |
# File 'lib/s3archive/s3_file_synchronizer.rb', line 67 def md5_hex exists? && headers.fetch("etag").tr('"', '') end |
#put(local_file) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/s3archive/s3_file_synchronizer.rb', line 75 def put(local_file) local_file.open do |file| logger.info("Putting '#{local_file}' to '#{self}'") s3interface.put(bucket, key, file, 'Content-MD5' => local_file.md5_base64) end end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/s3archive/s3_file_synchronizer.rb', line 82 def to_s "s3://#{bucket}/#{key}" end |