GetAppUpdateExcutor.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using LJProxy.LJLib.Net.SPI.Server;
  2. using LJProxy.Models;
  3. using LJProxy.Services;
  4. using Microsoft.AspNetCore.Http;
  5. using Microsoft.AspNetCore.Mvc;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text.RegularExpressions;
  10. using System.Threading.Tasks;
  11. namespace LJProxy.Excutor
  12. {
  13. public class GetAppUpdateExcutor : ExcutorBase<GetAppUpdateRequest>
  14. {
  15. VersionService _service = new VersionService();
  16. protected override IActionResult ExcuteInternal(GetAppUpdateRequest request, object state)
  17. {
  18. HttpRequest httpRequest = state as HttpRequest;
  19. Regex regx = new Regex(@"GetAppUpdate/(?<apkName>.*?\.apk)", RegexOptions.IgnoreCase);
  20. var matchResult=regx.Match(httpRequest.Path.ToString());
  21. if (matchResult.Success)
  22. {
  23. var apkName = matchResult.Groups["apkName"]?.Value;
  24. var fs = _service.GetAPK(apkName);
  25. if (fs==null)
  26. {
  27. return new NotFoundResult();
  28. }
  29. else
  30. {
  31. return new FileContentResult(fs, "application/vnd.android.package-archive");
  32. }
  33. }
  34. else
  35. {
  36. return new NotFoundResult();
  37. }
  38. }
  39. }
  40. }