我正在尝试选择一个视频,选择和显示视频都正常,但是当我尝试获取视频文件的完整路径时,我得到了错误的路径。
在下面的代码片段中,我正在尝试获取文件的完整路径:
Uri uri = Uri.parse(url);
File file = new File((uri.getPath()));
当我设置multipart实体的文件主体时,我传递给它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)