Sha256: 885953b508b78e7ca5b888908583b7a4238cbdad7bb5e5e9c0959bd06122e2ca

Contents?: true

Size: 713 Bytes

Versions: 4

Compression:

Stored size: 713 Bytes

Contents

require 'uri'
module IOStreams
  module S3
    autoload :Path, 'io_streams/s3/path'
    autoload :Reader, 'io_streams/s3/reader'
    autoload :Writer, 'io_streams/s3/writer'

    # Sample URI: s3://mybucket/user/abc.zip
    def self.parse_uri(uri)
      uri = URI.parse(uri)
      raise "Invalid URI. Required Format: 's3://<bucket_name>/<key>'" unless uri.scheme == 's3'
      {
        bucket: uri.host,
        key:    uri.path.sub(/\A\//, '')
      }
    end

    def self.load_dependencies
      return if defined?(::Aws::S3::Resource)

      require 'aws-sdk-s3'
    rescue LoadError => exc
      raise(LoadError, "Install gem 'aws-sdk-s3' to read and write AWS S3 files: #{exc.message}")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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