Fix non latin multipart file upload #210
Merged
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.
Summary
Current implementation of multipart file upload and
getFileInfo
on iOS doesn't support file names with non latin characters. This PR solves it. BTW, Android works fine withuseUtf8Charset: true
.Uploading file with non latin characters in filename results in empty NsData and incorrect httpBody content.
To use non latin filenames you need to do 2 things:
Original file path:
file:///private/var/mobile/Containers/Data/Application/A027BF30-70BE-4936-8233-08CED19F0B67/tmp/com.example.app-Inbox/Файл.pdf
Escaped file path:
file:///private/var/mobile/Containers/Data/Application/A027BF30-70BE-4936-8233-08CED19F0B67/tmp/com.example.app-Inbox/%D0%A4%D0%B0%D0%B9%D0%BB.pdf
I've failed to use
NSFileManager contentsAtPath
as file loader, so I had to change it toNSData dataWithContentsOfURL
. According to Apple iOS SDK comments, it's the preferred way to do it. I'm not an expert, so I'm open to other alternatives.Test Plan
What's required for testing (prerequisites)?
Rename any pdf file on your iOS device to
Файл.pdf
What are the steps to reproduce (after prerequisites)?
Try to upload
Файл.pdf
withuploadType='multipart'
. It will send incorrect http body.Try to
getFileInfo
ofФайл.pdf
. It will return an error.Compatibility