aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2017-07-06 15:31:31 -0400
committerGeorge Claghorn <george@basecamp.com>2017-07-06 15:31:31 -0400
commita2e864fa13c7d3d56a95a2f46d525597f989f938 (patch)
treeaee9df0c4c8786afdf1865b55a84fe2d0d7b56c3 /lib
parent2afe0a7d90403cca862644edeb8a2e393ccbddc6 (diff)
downloadrails-a2e864fa13c7d3d56a95a2f46d525597f989f938.tar.gz
rails-a2e864fa13c7d3d56a95a2f46d525597f989f938.tar.bz2
rails-a2e864fa13c7d3d56a95a2f46d525597f989f938.zip
Fix test
* S3 fails fast if the Content-MD5 header on an upload request is an invalid checksum. Send a valid but incorrect checksum. * Rescue the service-specific exception and raise the generic one.
Diffstat (limited to 'lib')
-rw-r--r--lib/active_storage/service/s3_service.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/active_storage/service/s3_service.rb b/lib/active_storage/service/s3_service.rb
index 413789e2b5..963a41af17 100644
--- a/lib/active_storage/service/s3_service.rb
+++ b/lib/active_storage/service/s3_service.rb
@@ -11,6 +11,8 @@ class ActiveStorage::Service::S3Service < ActiveStorage::Service
def upload(key, io, checksum: nil)
object_for(key).put(body: io, content_md5: checksum)
+ rescue Aws::S3::Errors::BadDigest
+ raise ActiveStorage::IntegrityError
end
def download(key)