React native react native中实际路径的uri
我使用react native document picker在Android和IOS中选择图像和视频。 问题是它返回一个uri,我需要实际路径 我尝试使用带有函数stat的react-native fetch blob和带有函数stat的react-native fs。两者都不适用于URI。但如果我使用react native fs readFile,它可以与URI一起工作 react native get real path仅适用于Android,因此不是一个选项 编辑: 有人建议我使用rn fetch blob,但我在安装时遇到问题:React native react native中实际路径的uri,react-native,path,uri,React Native,Path,Uri,我使用react native document picker在Android和IOS中选择图像和视频。 问题是它返回一个uri,我需要实际路径 我尝试使用带有函数stat的react-native fetch blob和带有函数stat的react-native fs。两者都不适用于URI。但如果我使用react native fs readFile,它可以与URI一起工作 react native get real path仅适用于Android,因此不是一个选项 编辑: 有人建议我使用rn
我尝试使用react native get real path来区分Android和IOS,但它也有问题。最后,我使用了ios的react-native document picker和android的react-native file picker最后,我使用了ios的react-native document picker和android的react-native file picker请正确格式化此代码,使其可读性更好。:)请正确设置此代码的格式,使其可读性更好。:)
File file = new File(getURIPath(uriValue));
/**
* URI Value
* @return File Path.
*/
String getURIPath(Uri uriValue)
{
String[] mediaStoreProjection = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(uriValue, mediaStoreProjection, null, null, null);
if (cursor != null){
int colIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String colIndexString=cursor.getString(colIndex);
cursor.close();
return colIndexString;
}
return null;
}