DEV: Update aws-sdk-s3 gem for S3 multipart uploads (#13523)

We are a few versions behind on this gem. We need to update it
for S3 multipart uploads. In the current version we are using, we
cannot do this:

```ruby
Discourse.store.s3_helper.object(key).presigned_url(:upload_part, part_number: 1, upload_id: multipart_upload_id)
```

The S3 client raises an error, saying the operation is undefined. Once
I updated the gem this operation works as expected and returns a
presigned URL for the upload_part operation.

Also remove use of Aws::S3::FileUploader::FIFTEEN_MEGABYTES.
This was part of a private API and should not have been used.
This commit is contained in:
Martin Brennan
2021-06-25 14:22:31 +10:00
committed by GitHub
parent 895df9c239
commit c3394ed9bb
2 changed files with 5 additions and 4 deletions

View File

@ -3,6 +3,7 @@
require "aws-sdk-s3"
class S3Helper
FIFTEEN_MEGABYTES = 15 * 1024 * 1024
class SettingMissing < StandardError; end
@ -42,8 +43,8 @@ class S3Helper
obj = s3_bucket.object(path)
etag = begin
if File.size(file.path) >= Aws::S3::FileUploader::FIFTEEN_MEGABYTES
options[:multipart_threshold] = Aws::S3::FileUploader::FIFTEEN_MEGABYTES
if File.size(file.path) >= FIFTEEN_MEGABYTES
options[:multipart_threshold] = FIFTEEN_MEGABYTES
obj.upload_file(file, options)
obj.load
obj.etag