IAzureBlobDBRepository.cs 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using TEAMModelOS.SDK.Module.AzureBlob.Container;
  2. using Microsoft.AspNetCore.Http;
  3. using System.Collections.Generic;
  4. using System.Threading.Tasks;
  5. using System.IO;
  6. using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
  7. namespace TEAMModelOS.SDK.Module.AzureBlob.Interfaces
  8. {
  9. public interface IAzureBlobDBRepository
  10. {
  11. Task<List<AzureBlobModel>> UploadFiles(IFormFile[] file ,string fileSpace="common" ,bool contentTypeDefault = false);
  12. Task<AzureBlobModel> UploadFile(IFormFile file, string fileSpace = "wordfiles", bool contentTypeDefault = true);
  13. Task<AzureBlobModel> UploadPath(string path, string fileSpace = "common", bool contentTypeDefault = false);
  14. Task<AzureBlobModel> UploadObject(string fileName, object obj, string fileSpace = "common", bool contentTypeDefault = true);
  15. Task<AzureBlobModel> UploadText(string fileName, string text, string fileSpace = "common", bool contentTypeDefault = true);
  16. Task<AzureBlobModel> UploadFileByFolder(Stream fileSteam, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true);
  17. Task<AzureBlobModel> UploadTextByFolder(string text, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true);
  18. AzureBlobModel UploadFileByFolderNAsyn(Stream fileSteam, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true);
  19. Task<string> GetBlobSasUri(string blobName, string containerName=null, string policyName = null);
  20. Task<string> GetBlobSasUriRead(string containerName, string blobName, string policyName = null);
  21. Task<(string, string, string)> GetContainerSasUri(string containerName=null, string policyName = null);
  22. Task<(string, string)> GetContainerSasUriRead(string containerName, string policyName = null);
  23. Task<bool> CreateSharedAccessPolicyAsync(string policyName , string containerName = null);
  24. Task DeleteSharedAccessPolicyAsync(string policyName, string containerName = null);
  25. Task Deleteblob(string sasUri);
  26. Task<List<BlobFileDto>> GetBlobDirectory(string containerName, string blobName);
  27. Task<Dictionary<string, object>> GetBlobSasUri(BlobSas blobSas,bool isRead);
  28. /// <summary>
  29. /// 获取某个文件的共享访问签名
  30. /// </summary>
  31. /// <param name="containerName"></param>
  32. /// <param name="blobName"></param>
  33. /// <returns></returns>
  34. Task<BlobAuth> GetBlobSasUriRead(string containerName, string blobName);
  35. /// <summary>
  36. /// 获取某个角色及对应的容器的共享访问签名
  37. /// </summary>
  38. /// <param name="blobSas"></param>
  39. /// <param name="isRead"></param>
  40. /// <returns></returns>
  41. Task<BlobAuth> GetContainerSasUri(BlobSas blobSas, bool isRead);
  42. /// <summary>
  43. /// 系统管理员 资源,题目关联,htex关联,学习活动学生上传文件关联,基本信息关联,教室平面图关联,评测冷数据关联
  44. /// "system": [ "res", "item", "htex", "task", "info", "room", "exam" ],
  45. /// 资源,题目关联,htex关联,学习活动学生上传文件关联,基本信息关联,教室平面图关联,评测冷数据关联
  46. /// "school": [ "res", "item", "htex", "task", "info", "room", "exam" ],
  47. /// 资源,题目关联,htex关联,学习活动关联,教师基本信息关联
  48. /// "teacher": [ "res", "item", "htex", "task", "info" ],
  49. /// 答案及学习活动上传的文件,学生基本信息关联
  50. ///"student": [ "stu/{studentId}/ans", "stu/{studentId}/task" ]
  51. /// </summary>
  52. /// <param name="name">容器名称</param>
  53. /// <param name="text">文件内容的流</param>
  54. /// <param name="folder">业务文件夹</param>
  55. /// <param name="fileName">文件名</param>
  56. /// <param name="contentTypeDefault">是否存放文件后缀对应的contentType</param>
  57. /// <returns></returns>
  58. Task<AzureBlobModel> UploadFileByContainer(string name, string text, string folder, string fileName, bool contentTypeDefault = true);
  59. }
  60. }