title: Unable to upload large file to mail draft using MS Graph
body: <p>I am getting the error: &quot;Stream doesn't support reading&quot;, when I am trying to upload large files in chunks to a mail draft using Microsoft Graph. I have tried doing the same with MemoryStream, this gives the same result.</p>
  <p>I am using .NET Framework 4.7.2, Microsoft Graph 3.27.0, Microsoft Graph Core 1.24.0.</p>
  <pre class="lang-cs prettyprint-override"><code>    public static async Task AttachFileAsync(
           GraphServiceClient graphClient,
           string draftMessageId,
           List&lt;Models.MailAttachment&gt; mailAttachments)
          {
              foreach (var mailattachment in mailAttachments)
              {
                  if (mailattachment.Data.LongLength &gt;= 3000000
                           &amp;&amp; mailattachment.Data.LongLength &lt;= 150000000)
                  {
                      var attachmentItem = new AttachmentItem
                      {
                          Name = mailattachment.Name,
                          Size = mailattachment.Data.LongLength
                      };
                      var uploadSession = await graphClient
                          .Me
                          .Messages[$&quot;{draftMessageId}&quot;]
                          .Attachments
                          .CreateUploadSession(attachmentItem)
                          .Request()
                          .PostAsync();
  
                      int chunkSize = 320 * 1024;
                      try
                      {
                          using (FileStream stream = System.IO.File.Open(attachmentItem.Name, FileMode.Open))
                          {
                              var uploadProvider = new ChunkedUploadProvider(uploadSession, graphClient, stream, chunkSize);
                              var chunks = uploadProvider.GetUploadChunkRequests();
                              var exceptions = new List&lt;Exception&gt;();
  
                              int iterations = 0;
                              foreach (var chunk in chunks)
                              {
                                  var chunkRequestResponse = await uploadProvider
                                      .GetChunkRequestResponseAsync(chunk, exceptions);
                                  if (!chunkRequestResponse.UploadSucceeded)
                                  {
                                      throw new Exception(&quot;Upload of mailAttachment failed.&quot;);
                                  }
                                  iterations++;
                              }
                          }
                      }
                      catch (Exception ex)
                      {
                          throw;
                      }
                  }
              }
          }
  </code></pre>
  <p>My stacktrace is:</p>
  <pre><code>StackTrace  &quot;   at Microsoft.Graph.HttpProvider.&lt;SendRequestAsync&gt;d__19.MoveNext()\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
     at Microsoft.Graph.HttpProvider.&lt;SendAsync&gt;d__18.MoveNext()\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
     at Microsoft.Graph.UploadChunkRequest.&lt;SendRequestAsync&gt;d__17.MoveNext()\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
     at Microsoft.Graph.UploadChunkRequest.&lt;PutAsync&gt;d__16.MoveNext()\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
     at Microsoft.Graph.ChunkedUploadProvider.&lt;GetChunkRequestResponseAsync&gt;d__18.MoveNext()\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n
     at graph_tutorial.Helpers.GraphHelper.&lt;AttachFileAsync&gt;d__6.MoveNext() in C:\\Users\\Flemming\\source\\repos\\msgraph-training-aspnetmvcapp\\graph-tutorial\\Helpers\\GraphHelper.cs:line 176&quot;   string
  </code></pre>