Sha256: 957397b32f49f32bcb9a8e53493db7eea3026f666b6d8405101384a65fbdf315

Contents?: true

Size: 493 Bytes

Versions: 1

Compression:

Stored size: 493 Bytes

Contents

module IOStreams
  module S3
    class Writer
      # Write to AWS S3
      def self.open(uri, region: nil, **args, &block)
        raise(ArgumentError, 'file_name must be a URI string') unless uri.is_a?(String)

        options = IOStreams::S3.parse_uri(uri)
        s3      = region.nil? ? Aws::S3::Resource.new : Aws::S3::Resource.new(region: region)
        object  = s3.bucket(options[:bucket]).object(options[:key])
        object.upload_stream(args, &block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iostreams-0.17.0 lib/io_streams/s3/writer.rb