-
Notifications
You must be signed in to change notification settings - Fork 346
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
[GITHUB-10139][Fix] Generated Swift code not working for multipart/form-data video upload #714
Conversation
…rm-data video upload
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.
@aman-v-singh Have we tested that this change doesn't affect existing flow. i.e. Other files which are in text format can sill be sent correctly in form-data body?
@aman-v-singh Could you also attach updated snippet here in description once? Also let's communicate this latest snippet with the User that reported this issue and make sure it works for them to get their feedback. |
@VShingala I have added the newly generated code above in the description and notified the user of the same.
The Newman tests take care of these different possibilities. |
@aman-v-singh There is a bit of catch with Which is why just wanted to make sure this is working correctly, could you give it a try manually and verify once? |
@VShingala these files and paths are generated on the fly when test case runs and this path gets updated locally. We usually don't commit the changes because it depends on the machine being run. |
@dhwaneetbhatt Thanks! Checked this out and Didn't know about this till now. This was a practice of habit for me while I was working on this as this file manipulation did not exist. 😅 For ref, below is code responsible for manipulation.
|
Context
Swift
code generated forContent-Type
multipart/form-data
.Root-Cause-Analysis
When the user was using the generated Swift code for uploading a
.MOV
video file, they were facing an issue on reaching this line:-let fileContent = String(data: fileData, encoding: .utf8)!
On analysis, it is found that the error is arising because the generated code is trying to encode video data in
UTF-8
format to be converted intoString
type, but we must realise every character infileData
would not be encodable inUTF-8
format.Solution
Instead of converting file data to
String
type, we will change thebody
variable fromString
toData
type. This way we don't have to convert thefileContent
toString
.For details refer to this answer.
Code Generated