Skip to content
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 non latin multipart file upload #210

Merged
merged 1 commit into from
May 5, 2021

Conversation

xvonabur
Copy link
Contributor

@xvonabur xvonabur commented Aug 7, 2020

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 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:

  1. Escape filepath

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

  1. Change method of loading file

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.

Compatibility

OS Implemented
iOS
Android

@reime005 reime005 merged commit 896cf32 into Vydia:master May 5, 2021
github-actions bot pushed a commit that referenced this pull request May 5, 2021
## [6.2.3](v6.2.2...v6.2.3) (2021-05-05)

### Bug Fixes

* non latin multipart file upload ([#210](#210)) ([896cf32](896cf32))
@github-actions
Copy link

github-actions bot commented May 5, 2021

🎉 This PR is included in version 6.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

benjamin777dev added a commit to benjamin777dev/react-native-upload that referenced this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants