-
Notifications
You must be signed in to change notification settings - Fork 303
Fixes #38482 - properly read data of ActionDispatch::Http::UploadedFile #11408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideEnsures uploaded files are properly read into raw data before being passed to the backend upload_chunk service, and adds a dedicated test to validate this behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @evgeni - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
To illustrate the difference, look how a RestClient request ends up with data in require 'rest-client'
x = RestClient.post('https://httpbin.org/post', {:content => '123', :multipart => true})
puts(x.body)
{
"args": {},
"data": "",
"files": {},
"form": {
"content": "123"
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
"Content-Length": "137",
"Content-Type": "multipart/form-data; boundary=----RubyFormBoundarye6tKlTzVaGTnwPlq",
"Host": "httpbin.org",
"User-Agent": "rest-client/2.1.0 (linux x86_64) ruby/3.4.2p28",
"X-Amzn-Trace-Id": "Root=1-6842c1d5-651aa08573ee4cb73499da57"
},
"json": null,
"origin": "134.19.2.92",
"url": "https://httpbin.org/post"
}import requests
x = requests.post('https://httpbin.org/post', files={'content': '123'})
print(x.content.decode())
{
"args": {},
"data": "",
"files": {
"content": "123"
},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "149",
"Content-Type": "multipart/form-data; boundary=6dcb82266e32ffc47cce9726a4347f68",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.32.3",
"X-Amzn-Trace-Id": "Root=1-6842c209-3494e6b43f90173d396017a1"
},
"json": null,
"origin": "134.19.2.92",
"url": "https://httpbin.org/post"
}To get RestClient to use irb(main):028> x = RestClient.post('https://httpbin.org/post', {:content => File.open('/tmp/l')})
=> <RestClient::Response 200 "{\n \"args\":...">
irb(main):029> puts(x.body)
{
"args": {},
"data": "",
"files": {
"content": "lol\n"
},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
"Content-Length": "178",
"Content-Type": "multipart/form-data; boundary=----RubyFormBoundaryPpuABAVAqyw2Gs30",
"Host": "httpbin.org",
"User-Agent": "rest-client/2.1.0 (linux x86_64) ruby/3.4.2p28",
"X-Amzn-Trace-Id": "Root=1-6842c678-3f5616972cd8f1710e796615"
},
"json": null,
"origin": "134.19.2.92",
"url": "https://httpbin.org/post"
}Technically, I think, using |
|
The test failures do not seem related? |
|
Out of curiosity, do you have an example about how to use this change with cURL or a Python client? |
|
I have theforeman/foreman-ansible-modules#1871 -- does that suffice? Or would you like a pure Python implementation? :) |
ianballou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
|
Feel free to merge when ready |
What are the changes introduced in this pull request?
Considerations taken when implementing this change?
What are the testing steps for this pull request?
Summary by Sourcery
Read file data when chunk-uploading content via ActionDispatch::Http::UploadedFile and ensure proper file upload behavior
Bug Fixes:
Tests: