Module: IOStreams::S3
- Defined in:
- lib/iostreams.rb,
lib/io_streams/s3.rb,
lib/io_streams/s3/reader.rb,
lib/io_streams/s3/writer.rb
Defined Under Namespace
Class Method Summary collapse
-
.parse_uri(uri) ⇒ Object
Sample URI: s3://mybucket/user/abc.zip.
Class Method Details
.parse_uri(uri) ⇒ Object
Sample URI: s3://mybucket/user/abc.zip
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/io_streams/s3.rb', line 11 def self.parse_uri(uri) # 's3://mybucket/user/abc.zip' uri = URI.parse(uri) # Filename and bucket only if uri.scheme.nil? segments = uri.path.split('/') raise "S3 URI must at the very least contain '<bucket_name>/<key>'" if (segments.size == 1) || (segments[0] == '') { bucket: segments.shift, key: segments.join('/') } end end |