title: Issue with Azure chunked upload to fileshare via Azure.Storage.Files.Shares library
body: <p>I'm trying to upload files to an Azure fileshare using the library Azure.Storage.Files.Shares.</p>
  
  <p>If I don't chunk the file (by making a single UploadRange call) it works fine, but for files over 4Mb I haven't been able to get the chunking working. The file is the same size when downloaded, but won't open in a viewer.</p>
  
  <p>I can't set smaller HttpRanges on a large file as I get a 'request body is too large' error, so I'm splitting the filestream into multiple mini streams and uploading the entire HttpRange of each of these</p>
  
  <pre><code>        ShareClient share = new ShareClient(Common.Settings.AppSettings.AzureStorageConnectionString, ShareName());
          ShareDirectoryClient directory = share.GetDirectoryClient(directoryName);
  
          ShareFileClient file = directory.GetFileClient(fileKey);
          using(FileStream stream = fileInfo.OpenRead())
          {
              file.Create(stream.Length);
  
              //file.UploadRange(new HttpRange(0, stream.Length), stream);
  
              int blockSize = 128 * 1024;
  
              BinaryReader reader = new BinaryReader(stream);
              while(true)
              {
                  byte[] buffer = reader.ReadBytes(blockSize);
                  if (buffer.Length == 0)
                      break;
  
                  MemoryStream uploadChunk = new MemoryStream();
                  uploadChunk.Write(buffer, 0, buffer.Length);
                  uploadChunk.Position = 0;
  
                  file.UploadRange(new HttpRange(0, uploadChunk.Length), uploadChunk);
              }
  
              reader.Close();
          }
  </code></pre>
  
  <p>The code above uploads without error, but when downloading the image from Azure it is corrupt.</p>
  
  <p>Does anyone have any ideas?  Thanks for any help you can provide.</p>
  
  <p>cheers</p>
  
  <p>Steve</p>