UploadController.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using Microsoft.AspNetCore.Mvc;
  2. using Common;
  3. using Services;
  4. using Infrastructure;
  5. namespace Controllers.Client
  6. {
  7. /// <summary>
  8. /// User)Controller
  9. /// </summary>
  10. // [ApiExplorerSettings(GroupName = "User")]
  11. public class UploadController : BaseController
  12. {
  13. private readonly IUploadService _UploadService;
  14. public UploadController(IUploadService UploadService)
  15. {
  16. _UploadService = UploadService;
  17. }
  18. /// <summary>
  19. /// 上传图片
  20. /// </summary>
  21. /// <param name="file">文件对象</param>
  22. /// <returns>上传图片</returns>
  23. [HttpPut]
  24. [Route("/v1/omega_upload/uploadImage")]
  25. public IActionResult uploadImage(IFormFile file)
  26. {
  27. string path = _UploadService.getPicPath(file);
  28. Dictionary<string, string> obj = new();
  29. var option = App.OptionsSetting;
  30. obj.Add("uploadUrl", option.Upload.UploadUrl + path);
  31. obj.Add("saveUrl", path);
  32. return SUCCESS(obj);
  33. }
  34. /// <summary>
  35. /// 上传文件
  36. /// </summary>
  37. /// <param name="file">文件对象</param>
  38. /// <returns>上传文件</returns>
  39. [HttpPut]
  40. [Route("/v1/omega_upload/uploadfile")]
  41. public IActionResult uploadFile(IFormFile file)
  42. {
  43. string path = _UploadService.getPicPath(file);
  44. Dictionary<string, string> obj = new();
  45. var option = App.OptionsSetting;
  46. obj.Add("uploadUrl", option.Upload.UploadUrl + path);
  47. obj.Add("saveUrl", path);
  48. return SUCCESS(obj);
  49. }
  50. }
  51. }