Sha256: 061702a4e94e5106cbaebad7d28f1c9510cc9aec99d13272a63ed5f7eb7f56d3
Contents?: true
Size: 945 Bytes
Versions: 4
Compression:
Stored size: 945 Bytes
Contents
module IOStreams module S3 class Reader # Read from a AWS S3 file def self.open(uri, region: nil, **args, &block) raise(ArgumentError, 'file_name must be a URI string') unless uri.is_a?(String) IOStreams::S3.load_dependencies # https://aws.amazon.com/blogs/developer/using-resources/ s3 = region.nil? ? Aws::S3::Resource.new : Aws::S3::Resource.new(region: region) options = IOStreams::S3.parse_uri(uri) object = s3.bucket(options[:bucket]).object(options[:key]) begin # Since S3 download only supports a push stream, write it to a tempfile first. IOStreams::File::Path.temp_file_name('iostreams_s3') do |file_name| args[:response_target] = file_name object.get(args) # Return a read stream IOStreams::File::Reader.open(file_name, &block) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.20.3 | lib/io_streams/s3/reader.rb |
iostreams-0.20.2 | lib/io_streams/s3/reader.rb |
iostreams-0.20.1 | lib/io_streams/s3/reader.rb |
iostreams-0.20.0 | lib/io_streams/s3/reader.rb |