我正在开发一个Android应用程序,我从图片库中取出并上传到Dropbox。我的问题是fileinputstream无法找到该文件。 请帮助代码如下,还有日志消息
public class UplodeFileToDropBox extends AsyncTask<Void , Void ,Boolean>{
private Context context ;
private DropboxAPI dropboxAPI ;
private File imagefile ;
private String dropboxpath ;
public UplodeFileToDropBox(Context context, DropboxAPI dropboxAPI, String dropboxpath, File imagefile)
{
super();
this.context = context ;
this.dropboxAPI = dropboxAPI ;
this.dropboxpath = dropboxpath ;
this.imagefile = imagefile ;
}
@Override
protected Boolean doInBackground(Void... voids) {
try
{
FileInputStream inputStream = new FileInputStream(imagefile);
Log.i("DbExampleLog", inputStream.toString());
dropboxAPI.putFile(dropboxpath, inputStream, imagefile.length(), null, null);
return true ;
}
catch (DropboxException e)
{
Log.i("DbexEpshon",e.getMessage() );
}
catch (FileNotFoundException e)
{
Log.i("DbExampleLog", e.getMessage());
}
return false ;
}
@Override
protected void onPostExecute(Boolean result) {
if (result)
{
Toast.makeText(context, "File has been upLoded", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(context , "Error wile loding" , Toast.LENGTH_LONG).show();
Log.e("DbExampleLog", "Something went wrong while uploading.");
}
}
}
记录消息
10-19 10:51:32.395 22850-23233/com.example.pige.dorpin I/DbExampleLog﹕ /external/images/media/31
10-19 10:51:32.395 22850-23233 / com.example.pige.dorpin I / DbExampleLog:/ external / images / media / 31:open failed:ENOENT(没有这样的文件或目录) 10-19 10:51:32.398 22850-23233 / com.example.pige.dorpin I / DbExampleLog:上传文件的转速为: