iostreams 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/io_streams/paths/s3.rb +26 -7
- data/lib/io_streams/stream.rb +1 -1
- data/lib/io_streams/version.rb +1 -1
- data/test/paths/s3_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1540cfa116ee75ceb9a5cedf8b3c4e89833fc69033e442ec6c5af990d626c427
|
4
|
+
data.tar.gz: 03a4bde845869ec7f3d7f54a7a5aed7f72dfaf999ab50f3435faf481927fb069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb60c37dcaa87cb5a76894c141e675039d369e3eb5e97079f63f60d15e00bce0f84f82ebeff8812829f85bd743118f09850ea5672f557550e5a26e0f0e9582b9
|
7
|
+
data.tar.gz: fab7d76db975e8e8b7f0051e83137b9debe4aeea6da865aa5f7d2e218650d4d789c20629fa9881fbdbdc3763fe89947fd660f0b7c494f955e67c4c9dedcbe175
|
data/lib/io_streams/paths/s3.rb
CHANGED
@@ -3,7 +3,7 @@ require "uri"
|
|
3
3
|
module IOStreams
|
4
4
|
module Paths
|
5
5
|
class S3 < IOStreams::Path
|
6
|
-
attr_reader :bucket_name, :client
|
6
|
+
attr_reader :bucket_name, :client, :options
|
7
7
|
|
8
8
|
# Arguments:
|
9
9
|
#
|
@@ -179,17 +179,36 @@ module IOStreams
|
|
179
179
|
#
|
180
180
|
# Notes:
|
181
181
|
# - Can copy across buckets.
|
182
|
+
# - No stream conversions are applied.
|
182
183
|
def move_to(target_path)
|
184
|
+
target = copy_to(target_path, convert: false)
|
185
|
+
delete
|
186
|
+
target
|
187
|
+
end
|
188
|
+
|
189
|
+
# Make S3 perform direct copies within S3 itself.
|
190
|
+
def copy_to(target_path, convert: true)
|
191
|
+
return super(target_path) if convert
|
192
|
+
|
183
193
|
target = IOStreams.new(target_path)
|
184
194
|
return super(target) unless target.is_a?(self.class)
|
185
195
|
|
186
196
|
source_name = ::File.join(bucket_name, path)
|
187
|
-
|
188
|
-
client.copy_object(bucket: target.bucket_name, key: target.path, copy_source: source_name)
|
189
|
-
delete
|
197
|
+
client.copy_object(options.merge(bucket: target.bucket_name, key: target.path, copy_source: source_name))
|
190
198
|
target
|
191
199
|
end
|
192
200
|
|
201
|
+
# Make S3 perform direct copies within S3 itself.
|
202
|
+
def copy_from(source_path, convert: true)
|
203
|
+
return super(source_path) if convert
|
204
|
+
|
205
|
+
source = IOStreams.new(source_path)
|
206
|
+
return super(source, **args) unless source.is_a?(self.class)
|
207
|
+
|
208
|
+
source_name = ::File.join(source.bucket_name, source.path)
|
209
|
+
client.copy_object(options.merge(bucket: bucket_name, key: path, copy_source: source_name))
|
210
|
+
end
|
211
|
+
|
193
212
|
# S3 logically creates paths when a key is set.
|
194
213
|
def mkpath
|
195
214
|
self
|
@@ -220,7 +239,7 @@ module IOStreams
|
|
220
239
|
# Shortcut method if caller has a filename already with no other streams applied:
|
221
240
|
def read_file(file_name)
|
222
241
|
::File.open(file_name, "wb") do |file|
|
223
|
-
client.get_object(
|
242
|
+
client.get_object(options.merge(response_target: file, bucket: bucket_name, key: path))
|
224
243
|
end
|
225
244
|
end
|
226
245
|
|
@@ -248,10 +267,10 @@ module IOStreams
|
|
248
267
|
# Use multipart file upload
|
249
268
|
s3 = Aws::S3::Resource.new(client: client)
|
250
269
|
obj = s3.bucket(bucket_name).object(path)
|
251
|
-
obj.upload_file(file_name)
|
270
|
+
obj.upload_file(file_name, options)
|
252
271
|
else
|
253
272
|
::File.open(file_name, "rb") do |file|
|
254
|
-
client.put_object(
|
273
|
+
client.put_object(options.merge(bucket: bucket_name, key: path, body: file))
|
255
274
|
end
|
256
275
|
end
|
257
276
|
end
|
data/lib/io_streams/stream.rb
CHANGED
data/lib/io_streams/version.rb
CHANGED
data/test/paths/s3_test.rb
CHANGED
@@ -138,7 +138,7 @@ module Paths
|
|
138
138
|
|
139
139
|
it "returns all the children under a sub-dir" do
|
140
140
|
write_raw_data
|
141
|
-
expected =
|
141
|
+
expected = %w[abd/test1.txt abd/test5.file].collect { |file_name| each_root.join(file_name) }
|
142
142
|
assert_equal expected.collect(&:to_s).sort, each_root.children("abd/*").collect(&:to_s).sort
|
143
143
|
end
|
144
144
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iostreams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|