![](/style/images/good.png)
![](/style/images/bad.png)
Fix s3 multipart uploads when threshold is larger than the file uploaded
source link: https://github.com/rails/rails/pull/40793
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Contributor
mullermp commented 11 days ago
Summary
Hello from AWS. A customer reported a bug in our repo (aws/aws-sdk-ruby#2451) around using :multipart_threshold
with ActiveStorage. The bug occurs when the file being uploaded has a smaller size than the multipart threshold. This happens because the :multipart_threshold
is passed into :put_object
, a parameter that is not understood by the s3 API. This results in a param validation failure. Please see the above issue for more details.
Other Information
I tested this by doing the following:
- Made a new rails app (
rails new --skip-javascript
) - Set the Gemfile to use my fork with
path:
- Configured ActiveStorage and S3 similar to https://edgeguides.rubyonrails.org/active_storage_overview.html
- Added
multipart_threshold: <%= 10.megabytes %>
under the:upload
and:amazon
keys. - Attempted to upload a file that was 38 kb, resulting in a failure (customer reproduction)
- Made the code change in my fork
- Attempted the same upload and it succeeded. I verified the object in my bucket.
As far as unit tests go, I'm not sure if you wanted an explicit test for this - I would assume it's not necessary in this case because it's a matter of what parameters are passed through to the SDK.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK