mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
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:
parent
895df9c239
commit
c3394ed9bb
|
@ -59,10 +59,10 @@ GEM
|
|||
aws-partitions (~> 1, >= 1.239.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.42.0)
|
||||
aws-sdk-kms (1.44.0)
|
||||
aws-sdk-core (~> 3, >= 3.112.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.90.0)
|
||||
aws-sdk-s3 (1.96.1)
|
||||
aws-sdk-core (~> 3, >= 3.112.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.1)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user