Class: Floccus::PutHelper
- Inherits:
-
Object
- Object
- Floccus::PutHelper
- Defined in:
- lib/floccus/put_helper.rb
Constant Summary collapse
- KB =
1024
Instance Method Summary collapse
-
#initialize(*args) ⇒ PutHelper
constructor
Setup.
-
#run ⇒ Object
Run the full command.
Constructor Details
Instance Method Details
#run ⇒ Object
Run the full command
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/floccus/put_helper.rb', line 17 def run file = open(@filename) # Instantiate a Progress Bar total_blocks = (file.size / KB).to_i + 2 = ProgressBar.create total: total_blocks # Create the object object = @s3.buckets[@cloud.bucket].objects[@hashed_filename] # Write the file object.write(content_length: file.size, acl: :public_read) do |buffer, bytes| buffer.write(file.read(bytes)) .increment end file.close public_url = if @cloud.use_domain? obj = object.public_url obj.scheme = "http" obj.host = @cloud.domain obj.path = obj.path.gsub("/#{@cloud.bucket}", "") obj else object.public_url end # Echo the results system "echo #{public_url} | pbcopy" puts "---> #{public_url}" end |