aws-sdk-resources 2.2.22 → 2.2.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6927f53e9941e05e1eb1b6b573ea5339108a47d7
4
- data.tar.gz: eccac718bb1c01430c925e6f52dcbccbc699e091
3
+ metadata.gz: 6a01b622bd2d85e55ec7ccec0a9dc9af44bb0797
4
+ data.tar.gz: 8205da57ea4f8a925bdb76f892bb88f6d581ab1c
5
5
  SHA512:
6
- metadata.gz: a094b814a59d8ee7c09e67c981aa71c85a4f4f81f6f4c35ab48238ba3b69003bbf7bae178100c76d20e83ee383de2311ba5e0d8ee297138788af08853a1847b7
7
- data.tar.gz: ef6c2872a289b7515df096520f433ccc296fddf0ee7732b494fc2d5e5d1fa339f11e0c3e7a186325d887f27d4dc74ced2f5ad0775ad1c8a1d74877ecc298c228
6
+ metadata.gz: 5058fefb5688a6805e4d49adc6f50c5c66049ac872e07967495f908ef46cdf9c5fd2ebbcc57bf9eed350d191716ae3b42adb900ced9f19964febb65c3e108d91
7
+ data.tar.gz: 2ff596c2648cf4520e94a893453d8f2c4b7c881649549551bd921e66405293d9efedcf65e90dd11378cebdd8633b3355d26d691af43b669d8f31a8994254db9a
@@ -5,14 +5,17 @@ module Aws
5
5
  alias size content_length
6
6
 
7
7
  # Copies another object to this object. Use `multipart_copy: true`
8
- # for large objects. This is required for objects that exceed 5GB.'
8
+ # for large objects. This is required for objects that exceed 5GB.
9
9
  #
10
- # @param [S3::Object, String, Hash] source Where to copy object
11
- # data from. `source` must be one of the following:
10
+ # @param [S3::Object, S3::ObjectVersion, S3::ObjectSummary, String, Hash] source
11
+ # Where to copy object data from. `source` must be one of the following:
12
12
  #
13
13
  # * {Aws::S3::Object}
14
- # * Hash - with `:bucket` and `:key`
15
- # * String - formatted like `"source-bucket-name/source-key"`
14
+ # * {Aws::S3::ObjectSummary}
15
+ # * {Aws::S3::ObjectVersion}
16
+ # * Hash - with `:bucket` and `:key` and optional `:version_id`
17
+ # * String - formatted like `"source-bucket-name/uri-escaped-key"`
18
+ # or `"source-bucket-name/uri-escaped-key?versionId=version-id"`
16
19
  #
17
20
  # @option options [Boolean] :multipart_copy (false) When `true`,
18
21
  # the object will be copied using the multipart APIs. This is
@@ -20,6 +23,20 @@ module Aws
20
23
  # performance improvements on large objects. Amazon S3 does
21
24
  # not accept multipart copies for objects smaller than 5MB.
22
25
  #
26
+ # @options options [Integer] :content_length Only used when
27
+ # `:multipart_copy` is `true`. Passing this options avoids a HEAD
28
+ # request to query the source object size.
29
+ #
30
+ # @options options [S3::Client] :copy_source_client Only used when
31
+ # `:multipart_copy` is `true` and the source object is in a
32
+ # different region. You do not need to specify this option
33
+ # if you have provided `:content_length`.
34
+ #
35
+ # @options options [String] :copy_source_region Only used when
36
+ # `:multipart_copy` is `true` and the source object is in a
37
+ # different region. You do not need to specify this option
38
+ # if you have provided a `:source_client` or a `:content_length`.
39
+ #
23
40
  # @example Basic object copy
24
41
  #
25
42
  # bucket = Aws::S3::Bucket.new('target-bucket')
@@ -15,7 +15,6 @@ module Aws
15
15
  copy_object(source, @object, merge_options(source, options))
16
16
  end
17
17
 
18
-
19
18
  def copy_to(target, options = {})
20
19
  copy_object(@object, target, merge_options(target, options))
21
20
  end
@@ -28,6 +27,7 @@ module Aws
28
27
  options[:key] = target_key
29
28
  options[:copy_source] = copy_source(source)
30
29
  if options.delete(:multipart_copy)
30
+ apply_source_client(source, options)
31
31
  ObjectMultipartCopier.new(@options).copy(options)
32
32
  else
33
33
  @object.client.copy_object(options)
@@ -37,8 +37,14 @@ module Aws
37
37
  def copy_source(source)
38
38
  case source
39
39
  when String then escape(source)
40
- when Hash then "#{source[:bucket]}/#{escape(source[:key])}"
41
- when S3::Object then "#{source.bucket_name}/#{escape(source.key)}"
40
+ when Hash
41
+ src = "#{source[:bucket]}/#{escape(source[:key])}"
42
+ src += "?versionId=#{source[:version_id]}" if source.key?(:version_id)
43
+ src
44
+ when S3::Object, S3::ObjectSummary
45
+ "#{source.bucket_name}/#{escape(source.key)}"
46
+ when S3::ObjectVersion
47
+ "#{source.bucket_name}/#{escape(source.object_key)}?versionId=#{source.id}"
42
48
  else
43
49
  msg = "expected source to be an Aws::S3::Object, Hash, or String"
44
50
  raise ArgumentError, msg
@@ -59,7 +65,7 @@ module Aws
59
65
  def merge_options(source_or_target, options)
60
66
  if Hash === source_or_target
61
67
  source_or_target.inject(options.dup) do |opts, (key, value)|
62
- opts[key] = value unless [:bucket, :key].include?(key)
68
+ opts[key] = value unless [:bucket, :key, :version_id].include?(key)
63
69
  opts
64
70
  end
65
71
  else
@@ -67,6 +73,22 @@ module Aws
67
73
  end
68
74
  end
69
75
 
76
+ def apply_source_client(source, options)
77
+
78
+ if source.respond_to?(:client)
79
+ options[:copy_source_client] ||= source.client
80
+ end
81
+
82
+ if options[:copy_source_region]
83
+ options[:copy_source_client] ||= S3::Client.new(
84
+ @object.client.config.to_h.merge(region: options.delete(:copy_source_region))
85
+ )
86
+ end
87
+
88
+ options[:copy_source_client] ||= @object.client
89
+
90
+ end
91
+
70
92
  def escape(str)
71
93
  Seahorse::Util.uri_path_escape(str)
72
94
  end
@@ -116,12 +116,12 @@ module Aws
116
116
  end
117
117
 
118
118
  def source_size(options)
119
- if options[:content_length]
120
- options.delete(:content_length)
121
- else
122
- bucket, key = options[:copy_source].match(/([^\/]+?)\/(.+)/)[1,2]
123
- @client.head_object(bucket:bucket, key:key).content_length
124
- end
119
+ return options.delete(:content_length) if options[:content_length]
120
+
121
+ client = options[:copy_source_client] || @client
122
+
123
+ bucket, key = options[:copy_source].match(/([^\/]+?)\/(.+)/)[1,2]
124
+ client.head_object(bucket: bucket, key: key).content_length
125
125
  end
126
126
 
127
127
  def default_part_size(source_size)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.22
4
+ version: 2.2.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.22
19
+ version: 2.2.23
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.22
26
+ version: 2.2.23
27
27
  description: Provides resource oriented interfaces and other higher-level abstractions
28
28
  for many AWS services. This gem is part of the official AWS SDK for Ruby.
29
29
  email: