AndroidMagic icon indicating copy to clipboard operation
AndroidMagic copied to clipboard

Does this library support InputStream as a parameter?

Open AndroidDeveloperLB opened this issue 5 years ago • 2 comments

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.

AndroidDeveloperLB avatar Jun 06 '19 06:06 AndroidDeveloperLB

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.

huzongyao avatar Jun 06 '19 10:06 huzongyao

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).

AndroidDeveloperLB avatar Jun 06 '19 10:06 AndroidDeveloperLB