2014-10-16 99 views
0

我想用Android的Live SDK上傳到One Drive,每次都會收到「空」作爲例外。OneDrive Android SDK上傳錯誤

這裏是我的代碼:從登錄

public void createFile(){ 
     Thread t = new Thread(new Runnable() 
     { 
      @Override 
      public void run() 
      { 

       String fileName = "UploadTest.txt"; 
       String filePath = Environment.getExternalStorageDirectory().toString() + File.separator + fileName; 
       File file = new File(filePth); 
       try { 
        final FileInputStream is = new FileInputStream(file); 
        client.uploadAsync("me/skydrive",file.getName(), is, new LiveUploadOperationListener() { 
         public void onUploadFailed(LiveOperationException exception, LiveOperation operation) { 

          Log.e("OneDrive","Error uploading file 1: " + exception.getMessage()); 
         } 

         public void onUploadCompleted(LiveOperation operation) { 

          Log.e("OneDrive","File uploaded."); 
          try { 
           is.close(); 
          } catch (IOException ioe) { 

           Log.e("OneDrive","Error uploading file 2: " + ioe.getMessage()); 
          } 
         } 

         public void onUploadProgress(int totalBytes, int bytesRemaining, LiveOperation operation) { 

         } 
        }); 
       } catch (IOException ioex) { 

        Log.e("OneDrive","Error uploading file 3: " + ioex.getMessage()); 
        return; 
       } catch (Exception ex) { 

        Log.e("OneDrive","Error uploading file 4: " + ex.getMessage()); 
        return; 
       } 
      } 
     }); 
     t.start(); 
} 

報告:

Error uploading file 4:null 

我想上傳到根目錄下。

請幫忙,謝謝。

+0

找出您正在捕捉哪個異常。消息是'null',所以打印出整個異常(可能調用toString)。 – Kai 2014-10-16 13:32:38

+0

http://ideone.com/PE4U21 ...有一個很大的機會,你得到NPE,所以你得到我的downvote ... prolly客戶端'是'null' – Selvin 2014-10-16 13:35:49

+0

@SelvinWell,感謝downvote。 我知道它是一個NPE,但我無法找出哪個部分是給它。 大多數路徑(我/ skydrive),可能......但微軟已經提到它作爲根路徑 – vkm 2014-10-16 13:39:42

回答