mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +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:
@ -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
|
||||
|
Reference in New Issue
Block a user