[英]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.