Sha256: 456689dc289d36bb34c367be6269eb736358baf7b3b4a1d0a8c14c2484e88ee3

Contents?: true

Size: 722 Bytes

Versions: 4

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true
module IOStreams
  module S3
    class Path < IOStreams::BasePath
      def initialize(path)
        IOStreams::S3.load_dependencies
        @s3      = Aws::S3::Resource.new
        @options = IOStreams::S3.parse_uri(path)
        @object  = s3.bucket(options[:bucket]).object(options[:key])
        super(path)
      end

      # S3 logically creates paths when a key is set.
      def mkpath
        self
      end

      def mkdir
        self
      end

      def exist?
        object.exists?
      end

      def size
        object.size
      end

      def delete
        object.delete
        self
      end

      private

      attr_reader :s3, :options, :object
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iostreams-0.20.3 lib/io_streams/s3/path.rb
iostreams-0.20.2 lib/io_streams/s3/path.rb
iostreams-0.20.1 lib/io_streams/s3/path.rb
iostreams-0.20.0 lib/io_streams/s3/path.rb