Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add multipart request support #65
base: master
Are you sure you want to change the base?
Add multipart request support #65
Changes from 3 commits
32dcce0
cc7096c
9783a3d
6ea240c
22f0492
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Gems related to mime types are known to allocate excessive memory. Have you looked into the mini_mime gem?
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.
Oh, I haven't thought about it.
Yup,
mini_mime
should work as expected too.And what do you think if we try to load mime types lib from users environment and if he does not have any mime types library then we throw an expection and enforce user to install mime types lib with a message_No mime types library detected you must add to your Gemfile
mime-types
ormini_mime
gem_?Code could look something like that:
It would nice for Rails users because Rails already includes
mime-types
gem.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.
That sounds like a good idea 👍
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.
It doesn't seem right to translate client errors to server errors. Also, you don't have to pass in the
e
to the second argument as Ruby captures the cause and users have access to it withexception#cause
.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.
oh, it was shamefully copy-pasted from
FaradayAdapter
So I cannot tell why it does looks so.
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.
should we use
Faraday::FilePart
orFaraday::ParamPart
based on this doc?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.
Mhm. Good point.
Faraday::UploadIO
will be deprecated. 😞 But inFaraday v0.17.0
UploadIO
is only valid way to add files to request.I think the next Faraday version will
v1.0
and it will haveFaraday::Parts
module where all parts of request will be described.Maybe we should specify
faraday
gem version in Gemfile just to make sure that for nowFaraday::UploadIO
could work?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.
In Ruby, duck typing is more preferable rather than checking classes.