diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-10-25 21:31:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 21:31:10 +0200 |
commit | e0f39626973fd9f5cce2d4cd3b166fb47e9c9059 (patch) | |
tree | e02d1e9a448960a68652f75baebb5921211ee7a1 /lib/paperclip | |
parent | c647fa99cab9b9db81d36223cf2c2c27e065b648 (diff) | |
parent | a30ac454b2ceb381c50f5b9323e25817d784a476 (diff) |
Merge pull request #1625 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'lib/paperclip')
-rw-r--r-- | lib/paperclip/storage_extensions.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/paperclip/storage_extensions.rb b/lib/paperclip/storage_extensions.rb new file mode 100644 index 000000000..95c35641e --- /dev/null +++ b/lib/paperclip/storage_extensions.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Some S3-compatible providers might not actually be compatible with some APIs +# used by kt-paperclip, see https://github.com/mastodon/mastodon/issues/16822 +if ENV['S3_ENABLED'] == 'true' && ENV['S3_FORCE_SINGLE_REQUEST'] == 'true' + module Paperclip + module Storage + module S3Extensions + def copy_to_local_file(style, local_dest_path) + log("copying #{path(style)} to local file #{local_dest_path}") + s3_object(style).download_file(local_dest_path, { mode: 'single_request' }) + rescue Aws::Errors::ServiceError => e + warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}") + false + end + end + end + end + + Paperclip::Storage::S3.prepend(Paperclip::Storage::S3Extensions) +end |