2016-10-12 21 views

答えて

0

これは、.NET Microsoft Graphクライアントライブラリの次のリリースで使用できます。 .NET OneDriveクライアントライブラリの機能と同じように動作します。私の仕事でこれを確認することができますbranch。レポでフィードバックを提供することができます。

+0

これは素晴らしいです!私はコードを見てみましょう。ありがとう。 – horacioj

+0

>/MIchaelMainer/workingブランチのコードをテストしたところ、うまくいきました。 実際には、仕事用のアカウントでは問題ありませんが、個人用アカウント(小規模のファイルでも)は失敗します(「認証に失敗しました」)。ドキュメンテーションは、これが作業アカウント機能であることについては何も述べていません。おそらくそれは?またはバグがありますか?バグの場合は、コードの中にどこにあるのかわかりません。なぜなら、1つの違いはアカウントの種類だからです。 (関連:https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/61) – horacioj

0

私は最近、Microsoft Graph .Net SDKを使用して書いたコードです。 GraphServiceClient(graphClient)認証が必要です。

if (fileSize.MegaBytes > 4) 
        { 
         var session = await graphClient.Drive.Root.ItemWithPath(uploadPath).CreateUploadSession().Request().PostAsync(); 
         var maxSizeChunk = 320 * 4 * 1024; 
         var provider = new ChunkedUploadProvider(session, graphClient, stream, maxSizeChunk); 
         var chunckRequests = provider.GetUploadChunkRequests(); 
         var exceptions = new List<Exception>(); 
         var readBuffer = new byte[maxSizeChunk]; 
         DriveItem itemResult = null; 
         //upload the chunks 
         foreach (var request in chunckRequests) 
         { 
          // Do your updates here: update progress bar, etc. 
          // ... 
          // Send chunk request 
          var result = await provider.GetChunkRequestResponseAsync(request, readBuffer, exceptions); 

          if (result.UploadSucceeded) 
          { 
           itemResult = result.ItemResponse; 
          } 
         } 

         // Check that upload succeeded 
         if (itemResult == null) 
         { 
          await UploadFilesToOneDrive(fileName, filePath, graphClient); 
         } 
        } 
        else 
        { 
         await graphClient.Drive.Root.ItemWithPath(uploadPath).Content.Request().PutAsync<DriveItem>(stream); 
        } 
関連する問題