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
Fix Error when cloning MultiPart File #1903
Fix Error when cloning MultiPart File #1903
Changes from 22 commits
74fb0d9
8a49b5c
9fa83af
9bb9168
d6e736b
a22208d
a52956f
601f09e
dfc81e2
1a07a42
f6b0ba2
f76480a
8439b3c
da66169
40001da
578ec78
0e7ab54
3499783
a8563c4
e7e7b9d
b794745
67fe9e6
0d329ca
528c5d6
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.
We can not remove this, as it will break current users. We need to keep the
stream
parameter here but add a@Deprecated
annotation on the whole constructor with a message thatclone()
will not work and that it will be removed in 6.0.0.Then add a new factory
MultipartFile.fromStream
with the newdata
parameter.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.
Okay, will do. If it's a new factory, it can't be called by other factories, right? Should I remove the other factories and make
data
a named parameter, so that the old constructor can still work? I'm sorry I'm a bit confused with thisThere 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.
Also, I believe what makes this solution work is that we're storing the stream generating method in
_data
, not the stream itselfThere 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.
Your solution looks great, thanks for the 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.
_data: () => stream
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.
I don't understand this as well, sorry. Shouldn't data be a method reference that will be stored in that internal parameter
_data
to be called when cloning? If I just make it a method that will deliver the old stream, the stream would have already been listened to when I try to clone it, resulting in the same error that was happening before. Could you please help me understand that?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.
To clarify, this is what I get when I make this change:
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.
Yea this was odd, not sure what Dart is doing there. I wrapped it in another pair of braces
(() => stream)
to please the compiler.