我正在尝试选择一个视频,选择和显示视频工作正常,但是当我尝试获取视频文件的完整路径时,我得到了错误的路径。
在以下代码片段中,我试图获取文件的完整路径:
Uri uri = Uri.parse(url);
File file = new File((uri.getPath()));
然后当我设置多部分实体文件体时,我将它传递给file.toString()
.
尝试上传文件时出现以下异常。
03-28 12:43:27.129: W/System.err(6018): java.io.FileNotFoundException: /content:/media/external/video/media/32398: open failed: ENOENT (No such file or directory)
03-28 12:43:27.157: W/System.err(6018): at libcore.io.IoBridge.open(IoBridge.java:416)
03-28 12:43:27.157: W/System.err(6018): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-28 12:43:27.157: W/System.err(6018): at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:92)
03-28 12:43:27.165: W/System.err(6018): at org.apache.http.entity.mime.HttpMultipart.doWriteTo(HttpMultipart.java:206)
03-28 12:43:27.165: W/System.err(6018): at org.apache.http.entity.mime.HttpMultipart.writeTo(HttpMultipart.java:224)
03-28 12:43:27.169: W/System.err(6018): at org.apache.http.entity.mime.MultipartEntity.writeTo(MultipartEntity.java:183)
03-28 12:43:27.169: W/System.err(6018): at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:97)
03-28 12:43:27.169: W/System.err(6018): at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:162)