我试图从Android保存图像文件,但出现错误。我已经为清单添加了读写权限。我想保存图像文件这样的文件路径(是这样的“内容://媒体/外部/图像/媒体/ 12”):从Android保存图像文件
File source = new File(filePath);
blob.upload(new FileInputStream(source), source.length());
的错误,我得到:
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: java.io.FileNotFoundException: content:/media/external/images/media/12: open failed: ENOENT (No such file or directory)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at libcore.io.IoBridge.open(IoBridge.java:452)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at com.example.gaya.searchpeople.PhotoInfoActivity$NetworkConnector.doInBackground(PhotoInfoActivity.java:103)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at com.example.gaya.searchpeople.PhotoInfoActivity$NetworkConnector.doInBackground(PhotoInfoActivity.java:75)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at java.lang.Thread.run(Thread.java:818)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at libcore.io.Posix.open(Native Method)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: at libcore.io.IoBridge.open(IoBridge.java:438)
04-13 09:27:05.453 6947-7534/com.example.gaya.searchpeople W/System.err: ... 9 more