Sha256: a1110992e17633a82f77c4bd1a951dc6e5a66aedd980dae7997335fd9b2ccd5a

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

require "stashify/file"

module Stashify
  class File
    module AWS
      # An implementation for interacting with files in AWS S3
      # buckets. The constructor needs an instance of Aws::S3::Bucket
      # order to know which bucket to interact with.
      class S3 < Stashify::File
        def initialize(bucket:, path:)
          @bucket = bucket
          super(path: path)
        end

        def contents
          @bucket.object(path).get.body.read
        end

        def write(contents)
          @bucket.object(path).put(body: contents)
        end

        def delete
          @bucket.object(path).delete
        end

        def exists?
          @bucket.object(path).exists?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stashify-aws-s3-1.2.0 lib/stashify/file/aws/s3.rb