diff options
-rw-r--r-- | lib/active_storage/service/s3_service.rb | 2 | ||||
-rw-r--r-- | test/service/shared_service_tests.rb | 4 |
2 files changed, 4 insertions, 2 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) diff --git a/test/service/shared_service_tests.rb b/test/service/shared_service_tests.rb index b4c888e77c..dfa0d61656 100644 --- a/test/service/shared_service_tests.rb +++ b/test/service/shared_service_tests.rb @@ -3,7 +3,7 @@ require "active_support/core_ext/securerandom" require "yaml" SERVICE_CONFIGURATIONS = begin - YAML.load_file(File.expand_path("../configurations.yml", __FILE__)).deep_symbolize_keys + YAML.load_file(File.expand_path("../configurations.yml", __FILE__)).deep_symbolize_keys rescue Errno::ENOENT puts "Missing service configuration file in test/services/configurations.yml" end @@ -44,7 +44,7 @@ module ActiveStorage::Service::SharedServiceTests data = "Something else entirely!" assert_raises(ActiveStorage::IntegrityError) do - @service.upload(key, StringIO.new(data), checksum: "BAD_CHECKSUM") + @service.upload(key, StringIO.new(data), checksum: Digest::MD5.base64digest("bad data")) end ensure @service.delete key |