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: .CSV files cannot be selected on Android using the type csv #695

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roge530
Copy link

@roge530 roge530 commented Jan 1, 2024

Resolve the issue on Android where .csv files cannot be selected
On /src/fileTypes.ts on line 4 the current version on master says:
csv: 'text/csv',

and I replace for:

csv: 'text/comma-separated-values',

With this change is possible to read csv files on Android as it should be expected. This works because when reading a .csv file using allFiles then accessing to the "type" property it returns "text/comma-separated-values".

For testing I provide this screenshots

Before the fix

image

Here I show the screen where the user is suppose to select a csv file

image

Here the user sees the file explorer, in this case the Downloads folder where I have a csv file, the csv file is display on the right window of vscode for reference of the content. We can see is a valid csv file but the code on the center window using

const res: DocumentPickerResponse = await DocumentPicker.pickSingle({ type: [DocumentPicker.types.csv], });

Does not allows use to pick the csv file

After the fix

image

With the fix the csv file is allowed to be picked

image

As we see, the file is read properly and can be used on the app

This should only apply to android devices, the emulator uses API 33, Android 13.0 Tiramisu

image

I run yarn typescript with 0 issues

image

Here is the differences between my branch and main

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

Resolve the issue on Android where .csv files cannot be selected
@vonovak
Copy link
Collaborator

vonovak commented Jan 9, 2024

Hello,
thank you for the PR. Can you share a little more information about what android you tested this with?

I think if we just merge this change, it will work better for some people, but it will stop working for some other people, so I'd like to find something that works for everyone.
Thank you 🙂

@roge530
Copy link
Author

roge530 commented Jan 13, 2024

Of course, on the next days I will upload some test with different versions of android, can you provide me with a range?

@vonovak
Copy link
Collaborator

vonovak commented Jan 18, 2024

Well, the more the better 🙂😄.
But I was also wondering what device you have experienced the issue with, I'm curious.
Thank you! 🙂

@roge530
Copy link
Author

roge530 commented Jan 20, 2024

Here are the details of the device

image

I´ve been bussy lately, I´m sorry for taking this long to answer

@vonovak
Copy link
Collaborator

vonovak commented Feb 18, 2024

hello @roge530 and thank you for your patience,
could you make the changes so that mimeTypes.csv actually maps to both text/csv and also text/comma-separated-values?

I guess one way to do it is to allow for mimeTypes to be a string, but also array of strings, and in this case the value would be ['text/csv', 'text/comma-separated-values']. Does that make sense?

The first value is the "standard" one but apparently google uses text/comma-separated-values. We should use both to make sure it works with both cases.

Thank you!

@kamiranoff
Copy link

hello @roge530 and thank you for your patience, could you make the changes so that mimeTypes.csv actually maps to both text/csv and also text/comma-separated-values?

I guess one way to do it is to allow for mimeTypes to be a string, but also array of strings, and in this case the value would be ['text/csv', 'text/comma-separated-values']. Does that make sense?

The first value is the "standard" one but apparently google uses text/comma-separated-values. We should use both to make sure it works with both cases.

Thank you!

That fixes it for me

@roge530
Copy link
Author

roge530 commented Sep 3, 2024

I´ll try this tomorrow
I´m very sorry I took me so long to add some feedback, I just try the array of strings but neither a real device or the emulator can use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants