我试图允许用户浏览视频并将其上传到Firebase存储,但是查看提供的示例,我不确定如何从指定文件转换为允许用户选择。提供的示例是:
Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg"));
StorageReference riversRef = storageRef.child("images/"+file.getLastPathSegment());
uploadTask = riversRef.putFile(file);
我使用ACTION_GET_CONTENT为用户打开文件浏览器,但是如何获取文件路径并替换第一行?
答案 0 :(得分:0)
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), YOUR_DIR_NAME);
if (!dir.exists()) {
dir.mkdir();
Log.d(LOG_TAG, "dir not exists and created first time");
} else {
Log.d(LOG_TAG, "dir exists");
}
String absPath = dir.getAbsoultePath();
Uri file = Uri.fromFile(new File(absPath + "rivers.jpg"));