2014-03-06 51 views
0

我目前正在開發一款支持android保險箱api的android應用程序。我成功地將文件發送到我的保管箱folder.now我想下載文件並保存到SD卡。在當我試圖下載文件的那一刻它給了我一個錯誤這個android-保險箱下載文件

DropboxServerException (nginx): 404 Not Found (File not found) 

這裏是我的代碼

public void downloadFiles(String filename){ 
     Log.i("filename is ",filename); 

     File mFile=new File(Environment.getExternalStorageDirectory().getPath() + "/Download1"); 
     try { 
      FileOutputStream mFileOutputStream=new FileOutputStream(mFile); 
      DropboxFileInfo mDropboxFileInfo=mApi.getFile(filename, null, mFileOutputStream, null); 
      } catch (FileNotFoundException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
      } catch (DropboxException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
      } 
    } 

文件名成功地打印在logcat的。並且該文件位於我的照片文件夾中的保存箱中。但我無法下載它。

+0

很可能您的文件路徑不正確。代碼中的其他部分看起來很好。 –

+0

哪些文件路徑?你是在說這行文件mFile =新文件(Environment.getExternalStorageDirectory()。getPath()+「/ Download1」); 這條路? – hellosheikh

+1

沒有..文件名..你需要得到它像「/ Photos /」+文件名,因爲你已經提到它是在你的照片文件夾中,而不是你的根。 –

回答

-2

文件名是問題所在。您需要像"/Photos/" + filename那樣得到它,因爲您已經提到它位於您的照片文件夾內而不在您的根目錄中。

DropboxFileInfo mDropboxFileInfo=mApi.getFile("/Photos/" + filename, null, mFileOutputStream, null);