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 with useUtf8Charset: 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:
Escape filepath
Original file path: file:///private/var/mobile/Containers/Data/Application/A027BF30-70BE-4936-8233-08CED19F0B67/tmp/com.example.app-Inbox/Файл.pdf
I've failed to use NSFileManager contentsAtPath as file loader, so I had to change it to NSData 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 with uploadType='multipart'. It will send incorrect http body.
Try to getFileInfo of Файл.pdf. It will return an error.
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 togetFileInfo
ofФайл.pdf
. It will return an error.Compatibility