alpha0010 / react-native-file-access

Filesystem access for React Native
MIT License
307 stars 19 forks source link

Add a "copyFileRes" function #19

Closed amsteromer closed 3 years ago

amsteromer commented 3 years ago

can you please add this feature?

copyFileRes(filename: string, destPath: string): Promise Copies the file named filename in the Android app's res folder and copies it to the given destPath path. res/drawable is used as the source parent folder for image files, res/raw for everything else.

i really need to use it with scoped storage :)

alpha0010 commented 3 years ago

What is the use case here, as compared to the assets/ folder? res/ files give compile time safety by generating ids, but these ids are only available from native code. It is possible to retrieve id by string name, but at that point, why not use assets?

https://developer.android.com/guide/topics/resources/providing-resources.html#OriginalFiles

amsteromer commented 3 years ago

@alpha0010 I'm having trouble with the time it takes to load sound files in my assets folder (I'm using react-native-sound, and whenever I load the files from my res folder it works much better and faster than loading it from the assets folder)

amsteromer commented 3 years ago

I would be very happy if you'd help me out

alpha0010 commented 3 years ago

Skimming over react-native-sound, it looks like they support asset:/example.mp3 to play example.mp3 directly from the assets/ folder. Is that what you are using that is slow?

amsteromer commented 3 years ago

@alpha0010 Yes, it causes problems playing/stopping the sound. Is there something I can do to help you implement the copyFileRes function?

alpha0010 commented 3 years ago

Live in v1.6.0.