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

Does this library support InputStream as a parameter? #3

Open
AndroidDeveloperLB opened this issue Jun 6, 2019 · 2 comments
Open

Comments

@AndroidDeveloperLB
Copy link

Or just file-path or File instance?

I ask because sadly Google plans to ruin the storage permission, and allow to use only SAF API to get access to files, and from there you can use InputStream and not File or file-path.

@huzongyao
Copy link
Owner

actually this library provided 'loadFromBytes()' api may solve your problem. it loads from memory bytes, and avoid permission problem, you may try pass the whole file bytes or maybe just first few kbs of the file, it could work.
https://github.com/huzongyao/AndroidMagic/blob/master/libmagic/src/main/java/com/hzy/libmagic/MagicApi.java

you mentioned Stream means continuing small bytes and loop read, but not whole file, it's a wonderful idea and I will check if the original lib support this operation.

@AndroidDeveloperLB
Copy link
Author

How could I know how many bytes to provide?
Don't the various file types need to have a minimal size for themselves, and some have a suffix of data and not just prefix?
The SAF API is truly a bad API, but that's the only thing that Google seems to be offering for all types of files. It's even very slow compared to the normal File API, at least in terms of folders-traversal (see here: https://issuetracker.google.com/issues/130261278 ) ...
I truly hope that Google will avoid this.
They already plan to ruin other types of apps too: apps that use the system-alert-window permission (allows to put content on top of other apps, floating), and clipboard apps (not being able to access it in the background).

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

No branches or pull requests

2 participants