LiquidPlayer / LiquidCore

Node.js virtual machine for Android and iOS
MIT License
1.01k stars 127 forks source link

Reading files from SD-card in microservice, Android #199

Open boby1975 opened 3 years ago

boby1975 commented 3 years ago

Could someone read the files from the SD card in the microservice? I get the error "access denied (EACCES)". But from the application where the microservice is running I can read this file. Of course the app has permission READ_EXTERNAL_STORAGE.

Someone knows how to get SD card read access from microservice? Thanks a lot.

1stRadiant commented 2 years ago

I don't know if you are still looking for an answer to this but here how's I did it: Create a method that reads files and returns content in your java. Then create a microservice event which runs readfile java method upon receiving the message from your javascript, then emits the read contents to your js code.

In your js code you need to also emit/send a message to your java code which includes and instruction to run the readfile method as well as the filename.

lastly you need to create an event which is triggered when your file is read this need's to happen after a millisecond so make sure you put set timeout above the event. This event will receive the contents of the file read, you can do whatever you want with value in node js.

I'll be happy to share the code if you need it just let me know.