2014-10-16 103 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

回答