AzureBlobModel.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using MessagePack;
  2. using Microsoft.AspNetCore.Http;
  3. using Microsoft.WindowsAzure.Storage.Table;
  4. using System;
  5. using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
  6. namespace TEAMModelOS.SDK.Module.AzureBlob.Container
  7. {
  8. [MessagePackObject(keyAsPropertyName: true)]
  9. public class AzureBlobModel : TableEntity
  10. {
  11. public AzureBlobModel()
  12. {
  13. long time = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
  14. Timestamp = DateTimeHelper.ConvertToDateTime(time);
  15. }
  16. public AzureBlobModel(IFormFile f, string Container ,string groupName ,string newName)
  17. {
  18. long time= DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
  19. ContentType = f.ContentType;
  20. ContentDisposition = f.ContentDisposition;
  21. FileName = f.FileName;
  22. // Headers = f.Headers.Values;
  23. RealName = groupName + "/"+ newName;
  24. Length = f.Length;
  25. Name = f.Name;
  26. UploadTime = time;
  27. PartitionKey = Container;
  28. RowKey = Guid.NewGuid().ToString();
  29. Extension = f.FileName.Substring(f.FileName.LastIndexOf(".") + 1, (f.FileName.Length - f.FileName.LastIndexOf(".") - 1)); //扩展名
  30. Timestamp = DateTimeHelper.ConvertToDateTime(time);
  31. }
  32. //
  33. // 摘要:
  34. // Gets the raw Content-Type header of the uploaded file.
  35. public string BlobUrl { get; set; }
  36. //
  37. // 摘要:
  38. // Gets the raw Content-Type header of the uploaded file.
  39. public string ContentType { get; set; }
  40. //
  41. // 摘要:
  42. // Gets the raw Content-Disposition header of the uploaded file.
  43. public string ContentDisposition { get; set; }
  44. //
  45. // 摘要:
  46. // Gets the header dictionary of the uploaded file.
  47. // public IHeaderDictionary Headers { get; set; }
  48. //
  49. // 摘要:
  50. // Gets the file length in bytes.
  51. public long Length { get; set; }
  52. //
  53. // 摘要:
  54. // Gets the form field name from the Content-Disposition header.
  55. public string Name { get; set; }
  56. //
  57. // 摘要:
  58. // Gets the file name from the Content-Disposition header.
  59. public string FileName { get; set; }
  60. public string RealName { get; set; }
  61. //上传时间戳
  62. public long UploadTime { get; set; }
  63. //上传扩展文件
  64. public string Extension { get; set; }
  65. }
  66. }