问题
I am looking for a file picker in react-native which returns me Absolute Path of the file picked. I am currently using react-native-document-picker, but it gives me the relative path in the format of content://com.android.providers.media.documents/document/......
. As I want to compress my video file, libraries like react-native-ffmpeg and react-native-video-processing require Absolute path of a file.
回答1:
I actually figured this out myself. You can get Absolute path in 3 ways.
The most convenient way : Use react-native-document-picker, on selection it will give you a Relative path, something like this content://com.android......
. Pass that Relative path to Stat(filepath) function of the react-native-fetch-blob
library. The object will return absolute path. Append the path with file://
to use it for further operations.
The other 2 ways are by using react-native-image picker and CameraRoll (React Native Library)
I hope this helps !
来源:https://stackoverflow.com/questions/52423067/how-to-get-absolute-path-of-a-file-in-react-native