![](/img/trans.png)
[英]File upload - Node Js(Express) to React Js. How to get correct image path?
[英]Android/NativeScript/JS. How to get absolute path including the file name from android media path?
我在nativescript中获得图像的媒体路径
我的代码:
var logoPath = argIntent.getParcelableExtra(Intent_1.EXTRA_STREAM);
但我知道这条路:
内容://媒体/外部/图像/媒体/ 152
如何从该路径获取包括文件名在内的绝对路径?
请在Nativescript / Javascript实现中! 如果有某种代码..
-
我需要类似的内容,但是使用javascript代码:
public static String getRealPathFromURI_API19(Context context, Uri uri){
String filePath = "";
String wholeID = DocumentsContract.getDocumentId(uri);
// Split at colon, use second item in the array
String id = wholeID.split(":")[1];
String[] column = { MediaStore.Images.Media.DATA };
// where id is equal to
String sel = MediaStore.Images.Media._ID + "=?";
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
column, sel, new String[]{ id }, null);
int columnIndex = cursor.getColumnIndex(column[0]);
if (cursor.moveToFirst()) {
filePath = cursor.getString(columnIndex);
}
cursor.close();
return filePath;
}
我该如何重写!!
字符串路径= yourAndroidURI.uri.getPath()//“ file:///mnt/sdcard/FileName.mp3”
文件文件=新文件(新URI(路径));
要么
字符串路径= yourAndroidURI.uri.toString()//“ /mnt/sdcard/FileName.mp3”
文件文件=新文件(新URI(路径));
也请参考此链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.