override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
this.context?.let {
data.run {
}.let {
val VideoPath = File(getPath(data.data), "video")
uploadVideo(VideoPath)
}
}
}
获取“真实uri”的函数
fun getPath(uri: Uri): String? {
val projection = arrayOf(MediaStore.Video.Media.DATA)
val cursor = activity!!.contentResolver.query(uri, projection, null, null, null)
if(cursor != null) {
val column_index = cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)
cursor.moveToFirst()
return cursor.getString(column_index)
} else
return null
}
我想要适合视频的uri,以便可以将其上传到我的api,然后将其作为文件格式。