Sha256: 6b5c348e5a10f092b1b98b20a52022436b48516a40304348eab54f13040f7592
Contents?: true
Size: 833 Bytes
Versions: 2
Compression:
Stored size: 833 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 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. temp_file = Tempfile.new('rocket_job') args[:response_target] = temp_file.to_path object.get(args) block.call(temp_file) ensure temp_file.delete if temp_file end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.17.2 | lib/io_streams/s3/reader.rb |
iostreams-0.17.1 | lib/io_streams/s3/reader.rb |