title: TaskCanceledException on large file upload to AWS S3
body: <p>I'm trying to upload a large video file (800mb) to my S3 bucket, but it appears to timeout. It works just fine for smaller files. My project is an ASP.Net Core 2.1 application.</p>
  
  <p>This is the exception that is thrown:</p>
  
  <blockquote>
    <p>An unhandled exception occurred while processing the request.
    SocketException: The I/O operation has been aborted because of either a thread exit or an application request.
    Unknown location</p>
    
    <p>IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request.
    System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs.ThrowException(SocketError error)</p>
    
    <p>TaskCanceledException: The operation was canceled.
    GamerPilot.Video.AWSS3Helper.UploadFileAsync(Stream stream, string key, S3CannedACL acl, bool useReducedRedundancy, bool throwOnError, CancellationToken cancellationToken) in AWSS3Helper.cs, line 770</p>
  </blockquote>
  
  <p>My source code looks like this:</p>
  
  <pre><code>  public async Task&lt;IVideo&gt; AddVideoAsync(int instructorId, int lectureId, string videoName, string filePath, CancellationToken cancellationToken = default(CancellationToken))
      {
          if (string.IsNullOrEmpty(filePath)) { throw new ArgumentNullException("filePath", "Video filepath is missing"); }
          if (!File.Exists(filePath)) { throw new ArgumentNullException("filePath", "Video filepath does not exists"); }
  
          //Test video file upload and db row insertion
          using (var stream = File.OpenRead(filePath))
          {
              return await AddVideoAsync(instructorId, lectureId, videoName, stream, cancellationToken);
          }
      }
  
   public async Task&lt;IVideo&gt; AddVideoAsync(int instructorId, int lectureId, string videoName, Stream videoFile, CancellationToken cancellationToken = default(CancellationToken))
      {
          var video = (Video) await GamerPilot.Video.Helper.Create(_awsS3AccessKey, _awsS3SecretKey, _awsS3BucketName, _awsS3Region)
              .AddVideoAsync(instructorId, lectureId, videoName, videoFile, cancellationToken);
  
          using (var db = new DbContext(_connectionString))
          {
              db.Videos.Add(video);
              var count = await db.SaveChangesAsync();
          }
  
          return video;
      }`
  
   public async Task&lt;IVideo&gt; AddVideoAsync(int instructorId, int lectureId, string videoName, Stream videoFile, CancellationToken cancellationToken = default(CancellationToken))
      {
          if (string.IsNullOrEmpty(videoName)) { throw new ArgumentNullException("videoName", "Video name cannot be empty or null"); }
          if (videoFile == null) { throw new ArgumentNullException("video", "Video stream is missing"); }
  
          var videoNameCleaned = videoName.Replace(" ", "-").ToLower().Replace(".mp4", "");
          var videoKey = string.Join('/', "videos", instructorId, lectureId, videoNameCleaned + ".mp4");
  
          using (var aws = new AWSS3Helper(_awsS3AccessKey, _awsS3SecretKey, _awsS3BucketName, _awsS3Region))
          {
              try
              {
                  //THIS FAILS ------
                  await aws.UploadFileAsync(videoFile, videoKey, Amazon.S3.S3CannedACL.PublicRead, true, true, cancellationToken);
  
              }
              catch (Exception ex)
              {
  
                  throw;
              }
          }
  
          return new Video
          {
              InstructorId = instructorId,
              LectureId = lectureId,
              Name = videoName,
              S3Key = videoKey,
              S3Region = _awsS3Region.SystemName,
              S3Bucket = _awsS3BucketName,
              Created = DateTime.Now
          };
      }
  </code></pre>
  
  <p>How can I work around this?</p>