carrierwave-aws 1.6.0 → 1.6.1
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5f21a2f65d6fc529886cc06a0b9a796d61775b249655519c0401336b0076383
|
|
4
|
+
data.tar.gz: 7c33f49c78db4c5996e6db75e8841864184db6e9a3c70186a982735f59c5c253
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5f7d35bfc4eaae8eef5a8c314b175c1e37a0394f19896c5ef96daf38c1d16ae37f269d03cb832f66765cfeba2b05d5339d0b6ea649fc0524e4614fd280268ca
|
|
7
|
+
data.tar.gz: 7277c6e4455acfc23dc2afd4f2e23d25bd5e550606c395151de2a75c969874cfd8b77b492d631c266c28f7f737d3c2a4cd07c679a1a12e404fb3022ec8e916da
|
|
@@ -57,6 +57,11 @@ module CarrierWave
|
|
|
57
57
|
def store(new_file)
|
|
58
58
|
if new_file.is_a?(self.class)
|
|
59
59
|
new_file.move_to(path)
|
|
60
|
+
elsif Aws::S3.const_defined?(:TransferManager)
|
|
61
|
+
options = aws_options.write_options(new_file).except(:body)
|
|
62
|
+
options[:multipart_threshold] = AWSOptions::MULTIPART_THRESHOLD
|
|
63
|
+
Aws::S3::TransferManager.new(client: connection.client).upload_file(new_file.path, bucket: bucket.name,
|
|
64
|
+
key: path, **options)
|
|
60
65
|
else
|
|
61
66
|
file.upload_file(new_file.path, aws_options.write_options(new_file))
|
|
62
67
|
end
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
module CarrierWave
|
|
4
4
|
module Storage
|
|
5
5
|
class AWSOptions
|
|
6
|
-
|
|
6
|
+
MULTIPART_THRESHOLD = 15 * 1024 * 1024
|
|
7
|
+
|
|
8
|
+
# Backward compatibility
|
|
9
|
+
MULTIPART_TRESHOLD = MULTIPART_THRESHOLD
|
|
7
10
|
|
|
8
11
|
attr_reader :uploader
|
|
9
12
|
|
|
@@ -26,7 +29,7 @@ module CarrierWave
|
|
|
26
29
|
def move_options(file)
|
|
27
30
|
{
|
|
28
31
|
acl: uploader.aws_acl,
|
|
29
|
-
multipart_copy: file.size >=
|
|
32
|
+
multipart_copy: file.size >= MULTIPART_THRESHOLD
|
|
30
33
|
}.merge(aws_attributes).merge(aws_write_options)
|
|
31
34
|
end
|
|
32
35
|
alias copy_options move_options
|
|
@@ -141,9 +141,36 @@ describe CarrierWave::Storage::AWSFile do
|
|
|
141
141
|
CarrierWave::SanitizedFile.new('spec/fixtures/image.png')
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
it 'uploads the file using
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
it 'uploads the file using TransferManager' do
|
|
145
|
+
client = instance_double('Aws::S3::Client')
|
|
146
|
+
|
|
147
|
+
allow(bucket).to receive(:name).and_return('example-com')
|
|
148
|
+
allow(connection).to receive(:client).and_return(client)
|
|
149
|
+
|
|
150
|
+
if Aws::S3.const_defined?(:TransferManager)
|
|
151
|
+
transfer_manager = instance_double('Aws::S3::TransferManager')
|
|
152
|
+
allow(Aws::S3::TransferManager).to receive(:new).with(client: client).and_return(transfer_manager)
|
|
153
|
+
|
|
154
|
+
expect(transfer_manager).to receive(:upload_file).with(
|
|
155
|
+
new_file.path,
|
|
156
|
+
bucket: 'example-com',
|
|
157
|
+
key: path,
|
|
158
|
+
acl: :'public-read',
|
|
159
|
+
content_type: new_file.content_type,
|
|
160
|
+
encryption_key: 'def',
|
|
161
|
+
multipart_threshold: CarrierWave::Storage::AWSOptions::MULTIPART_THRESHOLD
|
|
162
|
+
)
|
|
163
|
+
else
|
|
164
|
+
expect(file).to receive(:upload_file).with(
|
|
165
|
+
new_file.path,
|
|
166
|
+
hash_including(
|
|
167
|
+
acl: :'public-read',
|
|
168
|
+
content_type: new_file.content_type,
|
|
169
|
+
encryption_key: 'def'
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
end
|
|
173
|
+
|
|
147
174
|
aws_file.store(new_file)
|
|
148
175
|
end
|
|
149
176
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: carrierwave-aws
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Parker Selbert
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-s3
|
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
128
128
|
- !ruby/object:Gem::Version
|
|
129
129
|
version: '0'
|
|
130
130
|
requirements: []
|
|
131
|
-
rubygems_version: 3.
|
|
131
|
+
rubygems_version: 3.5.22
|
|
132
132
|
signing_key:
|
|
133
133
|
specification_version: 4
|
|
134
134
|
summary: Native aws-sdk support for S3 in CarrierWave
|