lib/utilities/s3.rb
# Upload a file to a S3 bucket.
Upload a file to a S3 bucket.
Upload a file to a S3 bucket .
def put(file, to: nil, swallow_ex: false)
      with_retries(rescue_ex: EXCEPTIONS, swallow_ex: swallow_ex, delay: 5) do
        basename    = File.basename(file)
        destination = to || basename
        content     = File.read(file)
        digest      = Digest::MD5.digest(content)
        CLIENT.put_object(
          bucket:      BUCKET,
          key:         File.join(PREFIX, destination),
          body:        content,
          content_md5: Base64.encode64(digest)
        )
      end
    end
def put ( file , to : nil , swallow_ex : false ) with_retries ( rescue_ex : EXCEPTIONS , swallow_ex : swallow_ex , delay : 5 ) do basename = File . basename ( file ) destination = to || basename content = File . read ( file ) digest = Digest :: MD5 . digest ( content ) CLIENT . put_object ( bucket : BUCKET , key : File . join ( PREFIX , destination ) , body : content , content_md5 : Base64 . encode64 ( digest ) ) end end
Upload a file to a S3 bucket.
Upload a file to a S3 bucket .
file
<not_specific>
to
<not_specific>
swallow_ex
<not_specific>