1
1

ResumeVirtualFileResultExecutor.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Masuit.Tools.AspNetCore.ResumeFileResults.Extensions;
  2. using Masuit.Tools.AspNetCore.ResumeFileResults.ResumeFileResult;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Mvc.Infrastructure;
  6. using Microsoft.Extensions.Logging;
  7. using System;
  8. using System.Threading.Tasks;
  9. namespace Masuit.Tools.AspNetCore.ResumeFileResults.Executor
  10. {
  11. /// <summary>
  12. /// 使用本地虚拟路径的可断点续传的FileResult
  13. /// </summary>
  14. internal class ResumeVirtualFileResultExecutor : VirtualFileResultExecutor, IActionResultExecutor<ResumeVirtualFileResult>
  15. {
  16. /// <summary>
  17. /// 执行FileResult
  18. /// </summary>
  19. /// <param name="context"></param>
  20. /// <param name="result"></param>
  21. /// <returns></returns>
  22. public virtual Task ExecuteAsync(ActionContext context, ResumeVirtualFileResult result)
  23. {
  24. if (context == null)
  25. {
  26. throw new ArgumentNullException(nameof(context));
  27. }
  28. if (result == null)
  29. {
  30. throw new ArgumentNullException(nameof(result));
  31. }
  32. context.SetContentDispositionHeaderInline(result);
  33. return base.ExecuteAsync(context, result);
  34. }
  35. public ResumeVirtualFileResultExecutor(ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment) : base(loggerFactory, hostingEnvironment)
  36. {
  37. }
  38. }
  39. }