CrazyIter 4 лет назад
Родитель
Сommit
c9ee77ebbb

+ 18 - 14
TEAMModelOS.SDK/DI/AzureCosmos/AzureCosmosFactory.cs

@@ -112,21 +112,25 @@ namespace TEAMModelOS.SDK.DI
             if (CosmosDict.typeCosmos.TryGetValue(typeName, out AzureCosmosModel AzureCosmosModel))
             {
                 return AzureCosmosModel;
-            }///如果没有则尝试默认创建
-            else
-            {
-                ContainerProperties containerProperties = new ContainerProperties { Id = cosmosDBAttribute.Name };
-                if (!string.IsNullOrEmpty(PartitionKey))
-                {
-                    containerProperties.PartitionKeyPath = "/" + PartitionKey;
-                }
-                CosmosDatabase database = GetCosmosClient().GetDatabase(cosmosDBAttribute.Database);
-                CosmosContainer  containerWithConsistentIndexing =await   database.CreateContainerIfNotExistsAsync(containerProperties, throughput: cosmosDBAttribute.RU);
-                AzureCosmosModel cosmosModel = new AzureCosmosModel { container = containerWithConsistentIndexing, cache = cosmosDBAttribute.Cache, monitor = cosmosDBAttribute.Monitor,database= database };
-                CosmosDict.nameCosmos.TryAdd(cosmosDBAttribute.Name, cosmosModel);
-                CosmosDict.typeCosmos.TryAdd(typeName, cosmosModel);
-                return cosmosModel;
             }
+            else {
+                return null;
+            }
+            ///如果没有则尝试默认创建
+            //    else
+            //    {
+            //        ContainerProperties containerProperties = new ContainerProperties { Id = cosmosDBAttribute.Name };
+            //        if (!string.IsNullOrEmpty(PartitionKey))
+            //        {
+            //            containerProperties.PartitionKeyPath = "/" + PartitionKey;
+            //        }
+            //        CosmosDatabase database = GetCosmosClient().GetDatabase(cosmosDBAttribute.Database);
+            //        CosmosContainer  containerWithConsistentIndexing =await   database.CreateContainerIfNotExistsAsync(containerProperties, throughput: cosmosDBAttribute.RU);
+            //        AzureCosmosModel cosmosModel = new AzureCosmosModel { container = containerWithConsistentIndexing, cache = cosmosDBAttribute.Cache, monitor = cosmosDBAttribute.Monitor,database= database };
+            //        CosmosDict.nameCosmos.TryAdd(cosmosDBAttribute.Name, cosmosModel);
+            //        CosmosDict.typeCosmos.TryAdd(typeName, cosmosModel);
+            //        return cosmosModel;
+            //    }
         }
         /// <summary>
         /// 初始化数据配置信息

+ 66 - 0
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs

@@ -2,6 +2,12 @@ using System.Threading.Tasks;
 using Azure.Storage;
 using Azure.Storage.Blobs;
 using Azure.Storage.Blobs.Models;
+using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
+using TEAMModelOS.SDK.Module.AzureBlob.Container;
+using TEAMModelOS.SDK.Context.Constant;
+using TEAMModelOS.SDK.Helper.Security.ShaHash;
+using System;
+using System.IO;
 
 namespace TEAMModelOS.SDK.DI
 {
@@ -29,5 +35,65 @@ namespace TEAMModelOS.SDK.DI
                 return null;
             }
         }
+
+        /// <summary>
+        /// 系统管理员 资源,题目关联,htex关联,学习活动学生上传文件关联,基本信息关联,教室平面图关联,评测冷数据关联
+        /// "system": [ "res", "item", "htex", "task", "info", "room", "exam" ],
+        /// 资源,题目关联,htex关联,学习活动学生上传文件关联,基本信息关联,教室平面图关联,评测冷数据关联
+        /// "school": [ "res", "item", "htex", "task", "info", "room", "exam" ],
+        /// 资源,题目关联,htex关联,学习活动关联,教师基本信息关联
+        /// "teacher": [ "res", "item", "htex", "task", "info" ],
+        /// 答案及学习活动上传的文件,学生基本信息关联
+        ///"student": [ "stu/{studentId}/ans", "stu/{studentId}/task" ]
+        /// </summary>
+        /// <param name="name">容器名称</param>
+        /// <param name="text">文件内容的流</param>
+        /// <param name="folder">业务文件夹</param>
+        /// <param name="fileName">文件名</param>
+        /// <param name="contentTypeDefault">是否存放文件后缀对应的contentType</param>
+        /// <returns></returns>
+        public static async Task<AzureBlobModel> UploadFileByContainer(this AzureStorageFactory azureStorageFactory, string name, string text, string folder, string fileName, bool contentTypeDefault = true)
+        {
+
+            // string groupName =folder;
+
+            BlobContainerClient blobContainer =  azureStorageFactory.GetBlobContainerClient(name.ToLower().Replace("#", "")); //blobClient.GetContainerReference(groupName); 
+            Uri url = blobContainer.Uri;
+
+            var blockBlob = blobContainer.GetBlobClient(folder + "/" + fileName);
+            string fileext = fileName.Substring(fileName.LastIndexOf(".") > 0 ? fileName.LastIndexOf(".") : 0);
+            string content_type = "application/octet-stream";
+            if (!contentTypeDefault)
+            {
+                ContentTypeDict.dict.TryGetValue(fileext, out string contenttype);
+                if (!string.IsNullOrEmpty(contenttype))
+                {
+                    content_type = contenttype;
+                    
+                    
+                }
+                else
+                {
+                   
+                    //blockBlob.Properties.ContentType = content_type;
+                }
+            }
+            else
+            {
+               
+                //blockBlob.Properties.ContentType = content_type;
+            }
+            byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
+            Stream streamBlob= new MemoryStream(bytes);
+            await blockBlob.UploadAsync(streamBlob);
+            blockBlob.SetHttpHeaders(new BlobHttpHeaders { ContentType = content_type });
+            AzureBlobModel model = new AzureBlobModel(fileName, name, folder, fileName, folder, content_type, bytes.Length)
+            {
+                Sha1Code = ShaHashHelper.GetSHA1(bytes),
+                BlobUrl = blockBlob.Uri.ToString()
+            };
+            return model;
+        }
+
     }
 }

+ 107 - 1
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageFactory.cs

@@ -15,6 +15,7 @@ using TEAMModelOS.SDK.Extension;
 using Azure.Storage.Queues;
 using TEAMModelOS.SDK.Context.Attributes.Azure;
 using System.Threading.Tasks;
+using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 
 namespace TEAMModelOS.SDK.DI
 {
@@ -61,7 +62,7 @@ namespace TEAMModelOS.SDK.DI
                 return null;
             }
         }
-
+        
         public BlobBatchClient GetBlobBatchClient(string name = "Default")
         {           
             try
@@ -120,6 +121,65 @@ namespace TEAMModelOS.SDK.DI
             }
         }
 
+        /// <summary>
+        /// 取得Blob Container SAS (有效期預設一天)
+        /// </summary>
+        /// <param name="containerName">容器名稱</param>
+        /// <param name="blobName"></param>
+        /// <param name="blobContainerSasPermissions"></param>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public BlobAuth GetContainerSasUri(BlobSas blobSas, bool isRead, string name = "Default")
+        {
+            try
+            {
+                string containerName = null;
+                var keys = Utils.ParseConnectionString(_optionsMonitor.Get(name).StorageAccountConnectionString);
+                var accountname = keys["AccountName"];
+                var accountkey = keys["AccountKey"];
+                var endpoint = keys["EndpointSuffix"];
+                if (blobSas.role == "system")
+                {
+                    containerName = "teammodelos";
+                }
+                else
+                {
+                    containerName = blobSas.name.ToLower().Replace("#", "");
+                }
+                DateTimeOffset dateTime = DateTimeOffset.UtcNow.Add(new TimeSpan(1, 0, 15, 0));
+                long time = dateTime.ToUnixTimeMilliseconds();
+                var blobSasBuilder = new BlobSasBuilder
+                {
+                    StartsOn = DateTimeOffset.UtcNow.Subtract(new TimeSpan(0, 15, 0)),
+                    ExpiresOn = dateTime,
+                    BlobContainerName = containerName
+                };
+                BlobContainerSasPermissions blobContainerSasPermissions = BlobContainerSasPermissions.Read;
+                if (isRead) {
+                    blobContainerSasPermissions = BlobContainerSasPermissions.Read;
+                }
+                else {
+                    blobContainerSasPermissions = BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Create | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List;
+                }
+                blobSasBuilder.SetPermissions(blobContainerSasPermissions);
+                var sskc = new StorageSharedKeyCredential(accountname, accountkey);
+                BlobSasQueryParameters sasQueryParameters = blobSasBuilder.ToSasQueryParameters(sskc);
+                UriBuilder fullUri = new UriBuilder()
+                {
+                    Scheme = "https",
+                    Host = $"{accountname}.blob.{endpoint}",
+                    Path = containerName
+                    //Query = sasQueryParameters.ToString()
+                };
+                return new BlobAuth { url = fullUri.Uri.ToString(), sas = sasQueryParameters.ToString(), timeout = time, name = containerName };
+               // return (fullUri.Uri.ToString(), sasQueryParameters.ToString());
+            }
+            catch
+            {
+                return   null ;
+            }
+        }
+
         /// <summary>
         /// 取得Blob SAS (有效期預設一天)
         /// </summary>
@@ -164,6 +224,52 @@ namespace TEAMModelOS.SDK.DI
             }
         }
 
+
+        /// <summary>
+        /// 取得Blob SAS (有效期預設一天)
+        /// </summary>
+        /// <param name="containerName">容器名稱</param>
+        /// <param name="blobName"></param>
+        /// <param name="blobSasPermissions"></param>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        public BlobAuth GetBlobSasUriRead(string containerName, string blobName,string name = "Default")
+        {
+            try
+            {
+                var keys = Utils.ParseConnectionString(_optionsMonitor.Get(name).StorageAccountConnectionString);
+                var accountname = keys["AccountName"];
+                var accountkey = keys["AccountKey"];
+                var endpoint = keys["EndpointSuffix"];
+                DateTimeOffset dateTime = DateTimeOffset.UtcNow.Add(new TimeSpan(1, 0, 15, 0));
+                long time = dateTime.ToUnixTimeMilliseconds();
+                var blobSasBuilder = new BlobSasBuilder
+                {
+                    StartsOn = DateTimeOffset.UtcNow.Subtract(new TimeSpan(0, 15, 0)),
+                    ExpiresOn = dateTime,
+                    BlobContainerName = containerName,
+                    BlobName = blobName
+                };
+
+                blobSasBuilder.SetPermissions(BlobSasPermissions.Read);
+                var sskc = new StorageSharedKeyCredential(accountname, accountkey);
+                BlobSasQueryParameters sasQueryParameters = blobSasBuilder.ToSasQueryParameters(sskc);
+                UriBuilder fullUri = new UriBuilder()
+                {
+                    Scheme = "https",
+                    Host = $"{accountname}.blob.{endpoint}",
+                    Path = $"{containerName}/{blobName}",
+                    Query = sasQueryParameters.ToString()
+                };
+                return new BlobAuth { url = fullUri.Uri.ToString(), sas = sasQueryParameters.ToString(), timeout = time };
+               // return fullUri.Uri.ToString();
+            }
+            catch
+            {
+                return null;
+            }
+        }
+
         public CloudTableClient GetCloudTableClient(string name = "Default")
         {            
             try

+ 112 - 97
TEAMModelOS.SDK/Module/AzureBlob/Implements/AzureBlobDBRepository.cs

@@ -32,7 +32,7 @@
 //        public AzureBlobDBRepository(IConfiguration configuration, IWebHostEnvironment env, AzureBlobOptions options, AzureBlobOptions azureBlobOptions)
 //        {
 //            Configuration = configuration;
-//           // BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath);
+//            // BaseConfigModel.SetBaseConfig(Configuration, env.ContentRootPath, env.WebRootPath);
 //            _options = options;
 //            if (!string.IsNullOrEmpty(options.ConnectionString))
 //            {
@@ -43,33 +43,33 @@
 
 //        public AzureBlobDBRepository()
 //        {
-             
+
 
 //        }
 
-//        private   CloudBlobContainer  InitializeBlob(string container)
+//        private CloudBlobContainer InitializeBlob(string container)
 //        {
 //            //https://teammodelstorage.blob.core.chinacloudapi.cn/wechatfilescontainer
-            
-//                // Type t = typeof(T);
-//                //若要将权限设置为仅针对 blob 的公共读取访问,请将 PublicAccess 属性设置为 BlobContainerPublicAccessType.Blob。
-//                //要删除匿名用户的所有权限,请将该属性设置为 BlobContainerPublicAccessType.Off。
-//                blobContainer = blobClient.GetContainerReference(_options .Container+"/"+ container);
-
-//                // await blobContainer.CreateIfNotExistsAsync();
-//                // BlobContainerPermissions permissions = await blobContainer.GetPermissionsAsync();
-//                // permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
-//                // await blobContainer.SetPermissionsAsync(permissions);
-            
+
+//            // Type t = typeof(T);
+//            //若要将权限设置为仅针对 blob 的公共读取访问,请将 PublicAccess 属性设置为 BlobContainerPublicAccessType.Blob。
+//            //要删除匿名用户的所有权限,请将该属性设置为 BlobContainerPublicAccessType.Off。
+//            blobContainer = blobClient.GetContainerReference(_options.Container + "/" + container);
+
+//            // await blobContainer.CreateIfNotExistsAsync();
+//            // BlobContainerPermissions permissions = await blobContainer.GetPermissionsAsync();
+//            // permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
+//            // await blobContainer.SetPermissionsAsync(permissions);
+
 //            return blobContainer;
 //        }
 
-//        public async Task<List<AzureBlobModel>> UploadFiles(IFormFile[] file,string fileSpace= "common" , bool contentTypeDefault = false)
+//        public async Task<List<AzureBlobModel>> UploadFiles(IFormFile[] file, string fileSpace = "common", bool contentTypeDefault = false)
 //        {
-//            string groupName = fileSpace+"/" +DateTime.Now.ToString("yyyyMMdd");
+//            string groupName = fileSpace + "/" + DateTime.Now.ToString("yyyyMMdd");
 //            string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss");
 //            // await InitializeBlob(DateTime.Now.ToString("yyyyMMdd"));
-//            blobContainer  =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName);
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName);
 //            //var serviceProperties = await blobClient.GetServicePropertiesAsync();
 //            //var corsSettings = serviceProperties.Cors;
 //            //var corsRule = corsSettings.CorsRules.FirstOrDefault(
@@ -94,25 +94,28 @@
 //            List<AzureBlobModel> list = new List<AzureBlobModel>();
 //            foreach (FormFile f in file)
 //            {
-               
+
 //                string[] names = f.FileName.Split(".");
 //                string name = "";
-//                for (int i = 0; i < names.Length-1; i++) {
+//                for (int i = 0; i < names.Length - 1; i++)
+//                {
 //                    name = name + names[i];
 //                }
 //                if (names.Length <= 1)
 //                {
 //                    name = f.FileName + "_" + newFileName;
 //                }
-//                else {
+//                else
+//                {
 //                    name = name + "_" + newFileName + "." + names[names.Length - 1];
 //                }
-//                string fileext = f.FileName.Substring(f.FileName.LastIndexOf(".")>0? f.FileName.LastIndexOf("."):0);
-                
+//                string fileext = f.FileName.Substring(f.FileName.LastIndexOf(".") > 0 ? f.FileName.LastIndexOf(".") : 0);
+
 //                var parsedContentDisposition = ContentDispositionHeaderValue.Parse(f.ContentDisposition);
 //                var filename = Path.Combine(parsedContentDisposition.FileName.Trim('"'));
 //                var blockBlob = blobContainer.GetBlockBlobReference(name);
-//                if (!contentTypeDefault) {
+//                if (!contentTypeDefault)
+//                {
 //                    ContentTypeDict.dict.TryGetValue(fileext, out string content_type);
 //                    if (!string.IsNullOrEmpty(content_type))
 //                    {
@@ -120,7 +123,7 @@
 //                    }
 //                }
 //                await blockBlob.UploadFromStreamAsync(f.OpenReadStream());
-//                string sha1= ShaHashHelper.GetSHA1(f.OpenReadStream());
+//                string sha1 = ShaHashHelper.GetSHA1(f.OpenReadStream());
 //                AzureBlobModel model = new AzureBlobModel(f, _options.Container, groupName, name)
 //                {
 //                    BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name,
@@ -130,10 +133,11 @@
 //            }
 //            return list;
 //        }
-//        public async Task<AzureBlobModel> UploadPath(string path, string fileSpace = "common" , bool contentTypeDefault = false) {
+//        public async Task<AzureBlobModel> UploadPath(string path, string fileSpace = "common", bool contentTypeDefault = false)
+//        {
 //            string groupName = fileSpace + "/" + DateTime.Now.ToString("yyyyMMdd");
 //            string newFileName = DateTime.Now.ToString("HHmmssfffffff");
-//            blobContainer =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName);
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName);
 //            StorageUri url = blobContainer.StorageUri;
 //            FileInfo file = new FileInfo(path);
 //            string[] names = file.Name.Split(".");
@@ -152,7 +156,7 @@
 //            }
 //            string fileext = file.Name.Substring(file.Name.LastIndexOf(".") > 0 ? file.Name.LastIndexOf(".") : 0);
 
-//          //  var parsedContentDisposition = ContentDispositionHeaderValue.Parse("form-data; name=\"files\"; filename=\"" + file.Name + "\"");
+//            //  var parsedContentDisposition = ContentDispositionHeaderValue.Parse("form-data; name=\"files\"; filename=\"" + file.Name + "\"");
 //            var blockBlob = blobContainer.GetBlockBlobReference(name);
 //            string content_type = "application/octet-stream";
 //            if (!contentTypeDefault)
@@ -175,9 +179,9 @@
 //            await blockBlob.UploadFromFileAsync(path);
 //            //var provider = new FileExtensionContentTypeProvider();
 //            //var memi = provider.Mappings[fileext];
-//            AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name , content_type)
+//            AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name, content_type)
 //            {
-//                Sha1Code=ShaHashHelper.GetSHA1(file.Create()),
+//                Sha1Code = ShaHashHelper.GetSHA1(file.Create()),
 //                BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
 //            };
 //            return model;
@@ -189,7 +193,7 @@
 //        {
 //            string groupName = fileSpace + "/" + DateTime.Now.ToString("yyyyMMdd");
 //            string newFileName = DateTime.Now.ToString("HHmmssfffffff");
-//            blobContainer =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
 //            StorageUri url = blobContainer.StorageUri;
 //            //FileInfo file = new FileInfo(path);
 //            string[] names = fileName.Split(".");
@@ -227,8 +231,8 @@
 //            {
 //                blockBlob.Properties.ContentType = content_type;
 //            }
-            
-        
+
+
 //            await blockBlob.UploadTextAsync(text);
 //            byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
 //            //var provider = new FileExtensionContentTypeProvider();
@@ -241,11 +245,11 @@
 //            return model;
 //        }
 
-//        public async Task<AzureBlobModel> UploadObject(string fileName,object obj, string fileSpace = "common", bool contentTypeDefault =true)
+//        public async Task<AzureBlobModel> UploadObject(string fileName, object obj, string fileSpace = "common", bool contentTypeDefault = true)
 //        {
 //            string groupName = fileSpace + "/" + DateTime.Now.ToString("yyyyMMdd");
 //            string newFileName = DateTime.Now.ToString("HHmmssfffffff");
-//            blobContainer =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
 //            StorageUri url = blobContainer.StorageUri;
 //            //FileInfo file = new FileInfo(path);
 //            string[] names = fileName.Split(".");
@@ -279,16 +283,17 @@
 //                    blockBlob.Properties.ContentType = content_type;
 //                }
 //            }
-//            else {
+//            else
+//            {
 //                blockBlob.Properties.ContentType = content_type;
 //            }
 //            string objStr = obj.ToJsonAbs();
-         
+
 //            await blockBlob.UploadTextAsync(objStr);
 //            //var provider = new FileExtensionContentTypeProvider();
 //            //var memi = provider.Mappings[fileext];
 //            byte[] bytes = System.Text.Encoding.Default.GetBytes(objStr);
-//            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type , bytes.Length)
+//            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, name, content_type, bytes.Length)
 //            {
 //                Sha1Code = ShaHashHelper.GetSHA1(bytes),
 //                BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
@@ -299,11 +304,11 @@
 
 //        public async Task<AzureBlobModel> UploadFile(IFormFile file, string fileSpace = "wordfiles", bool contentTypeDefault = true)
 //        {
-//            long  bizno= IdWorker.getInstance().NextId();
-//            string groupName = fileSpace + "/" + DateTime.Now.ToString("yyyyMMdd")+"/"+ bizno;
+//            long bizno = IdWorker.getInstance().NextId();
+//            string groupName = fileSpace + "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + bizno;
 //            string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss");
 //            // await InitializeBlob(DateTime.Now.ToString("yyyyMMdd"));
-//            blobContainer =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
 //            StorageUri url = blobContainer.StorageUri;
 //            string[] names = file.FileName.Split(".");
 //            string name = "";
@@ -334,22 +339,22 @@
 //            await blockBlob.UploadFromStreamAsync(file.OpenReadStream());
 //            string sha1 = ShaHashHelper.GetSHA1(file.OpenReadStream());
 //            AzureBlobModel model = new AzureBlobModel(file, _options.Container, groupName, name)
-//            {   
-//                Sha1Code=sha1,
+//            {
+//                Sha1Code = sha1,
 //                BlobUrl = url.PrimaryUri.ToString().Split("?")[0] + "/" + name
 //            };
 //            return model;
 //        }
 
 
-//        public  AzureBlobModel  UploadFileByFolderNAsyn(Stream fileSteam, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true)
+//        public AzureBlobModel UploadFileByFolderNAsyn(Stream fileSteam, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true)
 //        {
 
 //            string groupName = fileSpace + "/" + folder;
-//            blobContainer =   InitializeBlob(groupName);
+//            blobContainer = InitializeBlob(groupName);
 //            StorageUri url = blobContainer.StorageUri;
 //            string[] names = fileName.Split(".");
-            
+
 //            var blockBlob = blobContainer.GetBlockBlobReference(fileName);
 //            string fileext = fileName.Substring(fileName.LastIndexOf(".") > 0 ? fileName.LastIndexOf(".") : 0);
 //            if (!contentTypeDefault)
@@ -364,7 +369,7 @@
 //                    blockBlob.Properties.ContentType = "application/octet-stream";
 //                }
 //            }
-//            blockBlob.UploadFromStreamAsync(fileSteam).GetAwaiter().GetResult() ;
+//            blockBlob.UploadFromStreamAsync(fileSteam).GetAwaiter().GetResult();
 //            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, fileSteam.Length)
 //            {
 //                Sha1Code = ShaHashHelper.GetSHA1(fileSteam),
@@ -379,14 +384,14 @@
 
 //        public async Task<AzureBlobModel> UploadFileByFolder(Stream fileSteam, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true)
 //        {
-            
+
 //            string groupName = fileSpace + "/" + folder;
-//          //  string newFileName = sha1Code;
+//            //  string newFileName = sha1Code;
 //            // await InitializeBlob(DateTime.Now.ToString("yyyyMMdd"));
-//            blobContainer =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
 //            StorageUri url = blobContainer.StorageUri;
 //            string[] names = fileName.Split(".");
-//          //  string name ;
+//            //  string name ;
 //            //for (int i = 0; i < names.Length - 1; i++)
 //            //{
 //            //    name = name + names[i];
@@ -410,7 +415,8 @@
 //                {
 //                    blockBlob.Properties.ContentType = content_type;
 //                }
-//                else {
+//                else
+//                {
 //                    blockBlob.Properties.ContentType = "application/octet-stream";
 //                }
 //            }
@@ -428,9 +434,9 @@
 //        public async Task<AzureBlobModel> UploadTextByFolder(string text, string folder, string fileName, string fileSpace = "pptx", bool contentTypeDefault = true)
 //        {
 //            string groupName = fileSpace + "/" + folder;
-//            blobContainer =   InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
+//            blobContainer = InitializeBlob(groupName); //blobClient.GetContainerReference(groupName); 
 //            StorageUri url = blobContainer.StorageUri;
-        
+
 //            var blockBlob = blobContainer.GetBlockBlobReference(fileName);
 //            string fileext = fileName.Substring(fileName.LastIndexOf(".") > 0 ? fileName.LastIndexOf(".") : 0);
 //            string content_type = "application/octet-stream";
@@ -452,7 +458,7 @@
 //                blockBlob.Properties.ContentType = content_type;
 //            }
 
-            
+
 //            await blockBlob.UploadTextAsync(text);
 //            byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
 //            AzureBlobModel model = new AzureBlobModel(fileName, _options.Container, groupName, fileName, folder, blockBlob.Properties.ContentType, bytes.Length)
@@ -470,15 +476,15 @@
 //        /// <param name="container">A reference to the container.</param>
 //        /// <param name="policyName">The name of the stored access policy.</param>
 //        public async Task<bool> CreateSharedAccessPolicyAsync(string policyName,
-//            string  containerName = null)
+//            string containerName = null)
 //        {
-            
+
 //            blobContainer = await CreateContainer(_options.Container);
 //            //Create a new shared access policy and define its constraints.
 //            SharedAccessBlobPolicy sharedPolicy = new SharedAccessBlobPolicy()
 //            {
 //                SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(15),
-//                Permissions =  SharedAccessBlobPermissions.Delete
+//                Permissions = SharedAccessBlobPermissions.Delete
 //            };
 
 //            //Get the container's existing permissions.
@@ -500,14 +506,14 @@
 //        /// <param name="container">A reference to the container.</param>
 //        /// <param name="policyName">The name of the stored access policy.</param>
 //        public async Task DeleteSharedAccessPolicyAsync(string policyName,
-//            string  containerName = null)
+//            string containerName = null)
 //        {
-            
+
 //            blobContainer = await CreateContainer(_options.Container);
 //            BlobContainerPermissions permissions = await blobContainer.GetPermissionsAsync();
 //            permissions.SharedAccessPolicies.Remove(policyName);
 //            await blobContainer.SetPermissionsAsync(permissions);
-           
+
 //        }
 
 
@@ -522,7 +528,7 @@
 //        public async Task<(string, string, string)> GetContainerSasUri(string containerName = null, string storedPolicyName = null)
 //        {
 //            string sasContainerToken;
-           
+
 //            blobContainer = await CreateContainer(_options.Container);
 //            // If no stored policy is specified, create a new access policy and define its constraints.
 //            if (storedPolicyName == null)
@@ -535,7 +541,7 @@
 //                    // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew.
 //                    SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
 //                    SharedAccessExpiryTime = DateTime.UtcNow.AddHours(2),
-//                    Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create| SharedAccessBlobPermissions.Read
+//                    Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Read
 //                };
 
 //                // Generate the shared access signature on the container, setting the constraints directly on the signature.
@@ -552,8 +558,8 @@
 //            }
 
 //            // Return the URI string for the container, including the SAS token.
-            
-//            return (blobContainer.Uri.Scheme+ "://"+ blobContainer.Uri.Host.ToString() , blobContainer.Name, sasContainerToken);
+
+//            return (blobContainer.Uri.Scheme + "://" + blobContainer.Uri.Host.ToString(), blobContainer.Name, sasContainerToken);
 //        }
 //        public async Task<(string, string)> GetContainerSasUriRead(string containerName, string storedPolicyName = null)
 //        {
@@ -571,7 +577,7 @@
 //                    // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew.
 //                    SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
 //                    SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),
-//                    Permissions =  SharedAccessBlobPermissions.Read
+//                    Permissions = SharedAccessBlobPermissions.Read
 //                };
 
 //                // Generate the shared access signature on the container, setting the constraints directly on the signature.
@@ -606,15 +612,15 @@
 //        /// <param name="fileName">文件名</param>
 //        /// <param name="contentTypeDefault">是否存放文件后缀对应的contentType</param>
 //        /// <returns></returns>
-//        public async Task<AzureBlobModel> UploadFileByContainer(string name ,string  text, string folder, string fileName, bool contentTypeDefault = true)
+//        public async Task<AzureBlobModel> UploadFileByContainer(string name, string text, string folder, string fileName, bool contentTypeDefault = true)
 //        {
 
-//           // string groupName =folder;
+//            // string groupName =folder;
 
-//            blobContainer = await CreateContainer(name.ToLower().Replace("#","")); //blobClient.GetContainerReference(groupName); 
+//            blobContainer = await CreateContainer(name.ToLower().Replace("#", "")); //blobClient.GetContainerReference(groupName); 
 //            StorageUri url = blobContainer.StorageUri;
 
-//            var blockBlob = blobContainer.GetBlockBlobReference(folder+"/"+fileName);
+//            var blockBlob = blobContainer.GetBlockBlobReference(folder + "/" + fileName);
 //            string fileext = fileName.Substring(fileName.LastIndexOf(".") > 0 ? fileName.LastIndexOf(".") : 0);
 //            string content_type = "application/octet-stream";
 //            if (!contentTypeDefault)
@@ -674,31 +680,34 @@
 //                    Permissions = SharedAccessBlobPermissions.Read
 //                };
 //            }
-//            else {
+//            else
+//            {
 //                adHocPolicy = new SharedAccessBlobPolicy()
 //                {
 //                    // When the start time for the SAS is omitted, the start time is assumed to be the time when the storage service receives the request.
 //                    // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew.
 //                    SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
 //                    SharedAccessExpiryTime = dateTime,
-//                    Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Read| SharedAccessBlobPermissions.List
+//                    Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.List
 //                };
 //            }
 //            // Generate the shared access signature on the container, setting the constraints directly on the signature.
-//            string   sasContainerToken = blobContainer.GetSharedAccessSignature(adHocPolicy, null);
-           
-//            return new BlobAuth { url = blobContainer.Uri.AbsoluteUri.Replace(blobContainer.Uri.AbsolutePath,""), sas = sasContainerToken, timeout = time,name = blobContainer.Name };
+//            string sasContainerToken = blobContainer.GetSharedAccessSignature(adHocPolicy, null);
+
+//            return new BlobAuth { url = blobContainer.Uri.AbsoluteUri.Replace(blobContainer.Uri.AbsolutePath, ""), sas = sasContainerToken, timeout = time, name = blobContainer.Name };
 //        }
-//        public async Task<Dictionary<string,object>> GetBlobSasUri(BlobSas blobSas,bool isRead) {
+//        public async Task<Dictionary<string, object>> GetBlobSasUri(BlobSas blobSas, bool isRead)
+//        {
 //            string sasBlobToken;
 
 //            CloudBlobContainer blobContainer;
 //            if (blobSas.role == "system")
 //            {
-//                  blobContainer = await CreateContainer(_options.Container);
+//                blobContainer = await CreateContainer(_options.Container);
 //            }
-//            else {
-//                  blobContainer = await CreateContainer(blobSas.name.ToLower().Replace("#",""));
+//            else
+//            {
+//                blobContainer = await CreateContainer(blobSas.name.ToLower().Replace("#", ""));
 //            }
 //            // Create a new access policy and define its constraints.
 //            // Note that the SharedAccessBlobPolicy class is used both to define the parameters of an ad hoc SAS, and
@@ -733,10 +742,13 @@
 //            List<string> folders = BaseConfigModel.Configuration.GetSection("Azure:Blob:" + blobSas.role).Get<List<string>>();
 //            if (folders.IsNotEmpty())
 //            {
-//                foreach (string floder in folders) {
+//                foreach (string floder in folders)
+//                {
 //                    string cates = floder;
-//                    if (blobSas.role == "student") {
-//                        if (string.IsNullOrEmpty(blobSas.code)) {
+//                    if (blobSas.role == "student")
+//                    {
+//                        if (string.IsNullOrEmpty(blobSas.code))
+//                        {
 //                            throw new BizException("请设置学生编码!", ResponseCode.PARAMS_ERROR);
 //                        }
 //                        cates = floder.Replace("{studentId}", blobSas.code);
@@ -746,13 +758,13 @@
 //                    CloudBlockBlob blob = blobContainer.GetBlockBlobReference(cates);
 //                    // Generate the shared access signature on the blob, setting the constraints directly on the signature.
 //                    sasBlobToken = blob.GetSharedAccessSignature(adHocSAS);
-//                    dict.Add(cates, new { url=blob.Uri,sas=sasBlobToken , timeout = time });
+//                    dict.Add(cates, new { url = blob.Uri, sas = sasBlobToken, timeout = time });
 //                }
 //            }
 //            return dict;
 //        }
 
-   
+
 
 //        /// <summary>
 //        /// 若要为 blob 创建服务 SAS,请调用 CloudBlob.GetSharedAccessSignature 方法。
@@ -762,14 +774,14 @@
 //        /// <param name="blobName"></param>
 //        /// <param name="policyName"></param>
 //        /// <returns></returns>
-//        public async Task<string> GetBlobSasUri(string blobName, string containerName=null, string policyName = null)
+//        public async Task<string> GetBlobSasUri(string blobName, string containerName = null, string policyName = null)
 //        {
 //            string sasBlobToken;
-            
-//            blobContainer =await CreateContainer(_options.Container);
+
+//            blobContainer = await CreateContainer(_options.Container);
 //            // Get a reference to a blob within the container.
 //            // Note that the blob may not exist yet, but a SAS can still be created for it.
-//            CloudBlockBlob blob = blobContainer.GetBlockBlobReference( blobName );
+//            CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blobName);
 //            if (policyName == null)
 //            {
 //                // Create a new access policy and define its constraints.
@@ -781,7 +793,7 @@
 //                    // Omitting the start time for a SAS that is effective immediately helps to avoid clock skew.
 //                    SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
 //                    SharedAccessExpiryTime = DateTime.UtcNow.AddHours(2),
-//                    Permissions =  SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Read
+//                    Permissions = SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.Create | SharedAccessBlobPermissions.Read
 //                };
 
 //                // Generate the shared access signature on the blob, setting the constraints directly on the signature.
@@ -808,7 +820,7 @@
 //            return blobProperties;
 //        }
 
-//        public List<BlobFileDto> GetBlobProperties(List<BlobFileDto> blobProperties, CloudBlobDirectory blobDirectory) 
+//        public List<BlobFileDto> GetBlobProperties(List<BlobFileDto> blobProperties, CloudBlobDirectory blobDirectory)
 //        {
 //            IEnumerable<IListBlobItem> listBlobItems1 = blobDirectory.ListBlobsSegmentedAsync(new BlobContinuationToken()).GetAwaiter().GetResult().Results;
 //            foreach (IListBlobItem listBlobItem in listBlobItems1)
@@ -849,7 +861,7 @@
 //                {
 //                    SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-15),
 //                    SharedAccessExpiryTime = DateTime.UtcNow.AddHours(2),
-//                    Permissions =  SharedAccessBlobPermissions.Read
+//                    Permissions = SharedAccessBlobPermissions.Read
 //                };
 //                sasBlobToken = blob.GetSharedAccessSignature(adHocSAS);
 
@@ -877,7 +889,7 @@
 //            return new BlobAuth { url = blob.Uri.ToString(), sas = sasBlobToken, timeout = time };
 //        }
 
-        
+
 
 //        private async Task<CloudBlobContainer> CreateContainer(string containerName)
 //        {
@@ -893,16 +905,17 @@
 //            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
 //            CloudBlobContainer container = blobClient.GetContainerReference(containerName);
 //            bool a = await container.ExistsAsync();
-//            if (!a) {
-//                throw new BizException("容器不存在!",ResponseCode.PARAMS_ERROR);
+//            if (!a)
+//            {
+//                throw new BizException("容器不存在!", ResponseCode.PARAMS_ERROR);
 //            }
-//           // await container.CreateIfNotExistsAsync();
+//            // await container.CreateIfNotExistsAsync();
 //            return container;
 //        }
 
 //        public async Task Deleteblob(string azureBlobSAS)
 //        {
-            
+
 //            (string, string) a = BlobUrlString(azureBlobSAS);
 //            string ContainerName = a.Item1;
 //            string BlobName = a.Item2;
@@ -918,11 +931,13 @@
 //                }
 //                // await DeleteSharedAccessPolicyAsync(PolicyName);
 //            }
-//            catch (Exception e) {
+//            catch (Exception e)
+//            {
 
 //                throw new BizException(e.StackTrace);
 //            }
-//            finally {
+//            finally
+//            {
 //                await DeleteSharedAccessPolicyAsync(PolicyName);
 //            }
 //        }

+ 10 - 9
TEAMModelOS/Controllers/Core/BlobController.cs

@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Configuration;
 using System;
 using System.Collections.Generic;
@@ -12,6 +12,7 @@ using TEAMModelOS.SDK.Helper.Common.JsonHelper;
 using TEAMModelOS.SDK.Helper.Network.HttpHelper;
 using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
 using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
+using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelOS.Controllers.Core
 {
@@ -20,8 +21,8 @@ namespace TEAMModelOS.Controllers.Core
     public class BlobController : BaseController
     {
         
-        private readonly IAzureBlobDBRepository azureBlobDBRepository;
-        public BlobController(IAzureBlobDBRepository _azureBlobDBRepository) {
+        private readonly AzureStorageFactory azureBlobDBRepository;
+        public BlobController(AzureStorageFactory _azureBlobDBRepository) {
             azureBlobDBRepository = _azureBlobDBRepository;
         }
 
@@ -31,13 +32,13 @@ namespace TEAMModelOS.Controllers.Core
         /// <param name="request"></param>
         /// <returns></returns>
         [HttpPost("blobSasR")]
-        public async Task<BaseResponse> BlobSasR(JosnRequest<BlobSas> request)
+        public    BaseResponse  BlobSasR(JosnRequest<BlobSas> request)
         {
             ///返回金钥过期时间
             ResponseBuilder builder = new ResponseBuilder();
             // Dictionary<string, object> dict = await azureBlobDBRepository.GetBlobSasUri(request.@params,true);
            // dict.Add(d.Key, d.Value);
-            return builder.Data(await azureBlobDBRepository.GetContainerSasUri(request.@params, true)).build() ;
+            return builder.Data(  azureBlobDBRepository.GetContainerSasUri(request.@params, true)).build() ;
         }
         /// <summary>
         /// 某个文件的上传SAS rcw权限
@@ -52,7 +53,7 @@ namespace TEAMModelOS.Controllers.Core
             // Dictionary<string,object> dict=  await azureBlobDBRepository.GetBlobSasUri(request.@params,false);
          //   Dictionary<string, object> dict = ;
             //dict.Add(d.Key, d.Value);
-            return builder.Data(await azureBlobDBRepository.GetContainerSasUri(request.@params, false)).build();
+            return builder.Data(  azureBlobDBRepository.GetContainerSasUri(request.@params, false)).build();
         }
         /// <summary>
         /// 链接只读(读)
@@ -70,7 +71,7 @@ namespace TEAMModelOS.Controllers.Core
             bool flg = IsBlobName(BlobName);
             if (flg)
             {
-                return responseBuilder.Data(await azureBlobDBRepository.GetBlobSasUriRead(ContainerName, BlobName)).build();
+                return responseBuilder.Data(  azureBlobDBRepository.GetBlobSasUriRead(ContainerName, BlobName)).build();
             }
             else {
                 return responseBuilder.Error(ResponseCode.PARAMS_ERROR,"文件名错误").build();
@@ -92,7 +93,7 @@ namespace TEAMModelOS.Controllers.Core
             bool flg = IsBlobName(BlobName);
             if (flg)
             {
-                BlobAuth blobAuth=  await azureBlobDBRepository.GetBlobSasUriRead(ContainerName, BlobName);
+                BlobAuth blobAuth=    azureBlobDBRepository.GetBlobSasUriRead(ContainerName, BlobName);
                 string  text= await HttpHelper.HttpGetAsync(blobAuth.url + blobAuth.sas);
                 JsonElement json = text.FromApiJson<JsonElement>();
                 return responseBuilder.Data(json).build();
@@ -113,7 +114,7 @@ namespace TEAMModelOS.Controllers.Core
         public async Task<BaseResponse> UploadText(JosnRequest<string> request)
         {
             ResponseBuilder responseBuilder = new ResponseBuilder();
-            return responseBuilder.Data(await azureBlobDBRepository.UploadFileByContainer("hbcn",request.@params,"exam",Guid.NewGuid().ToString()+".json")).build();
+            return responseBuilder.Data(await azureBlobDBRepository.UploadFileByContainer("hbcn", request.@params, "exam", Guid.NewGuid().ToString() + ".json")).build();
           
         }
         private static string ContainerUrlString(string sasUrl)

+ 53 - 53
TEAMModelOS/Controllers/Core/FileController.cs

@@ -33,60 +33,60 @@ namespace TEAMModelOS.Controllers
         }
 
 
-        [HttpPost("uploadFiles")]
-        [RequestSizeLimit(204_800_000_00)] //最大20000m左右
-        public async Task<BaseResponse> BlobSaveFile([FromForm] IFormFile[] files)
-        {
-            ResponseBuilder responseBuilder = new ResponseBuilder();
-            FileTypeMap fileTypeMap = new FileTypeMap();
-            fileTypeMap.GetFileTypes().TryGetValue(FileType.GetExtention(files[0].FileName).ToLower(), out FileType fileTpye);
-            string type = "";
-            if (fileTpye != null)
-            {
-                type = fileTpye.Type;
-            }
-
-            List<AzureBlobModel> list = await _azureBlobDBRepository.UploadFiles(files);
-            await azureTableDBRepository.SaveAll<AzureBlobModel>(list);
-            return responseBuilder.Data(list).build();
-        }
-        [HttpPost("uploadFile")]
-        [RequestSizeLimit(204_800_000_00)] //最大20000m左右
-        public async Task<BaseResponse> BlobSaveFile([FromForm] IFormFile file)
-        {
-            //IFormFileCollection s =  Request.Form.Files;
-            ResponseBuilder responseBuilder = new ResponseBuilder();
-            FileTypeMap fileTypeMap = new FileTypeMap();
-            fileTypeMap.GetFileTypes().TryGetValue(FileType.GetExtention(file.FileName).ToLower(), out FileType fileTpye);
-            string type = "";
-            if (fileTpye != null)
-            {
-                type = fileTpye.Type;
-            }
-            List<IFormFile> files = new List<IFormFile>();
-            files.Add(file);
-            List<AzureBlobModel> list = await _azureBlobDBRepository.UploadFiles(files.ToArray());
-            await azureTableDBRepository.SaveAll<AzureBlobModel>(list);
-            return responseBuilder.Data(list).build();
-        }
+        //[HttpPost("uploadFiles")]
+        //[RequestSizeLimit(204_800_000_00)] //最大20000m左右
+        //public async Task<BaseResponse> BlobSaveFile([FromForm] IFormFile[] files)
+        //{
+        //    ResponseBuilder responseBuilder = new ResponseBuilder();
+        //    FileTypeMap fileTypeMap = new FileTypeMap();
+        //    fileTypeMap.GetFileTypes().TryGetValue(FileType.GetExtention(files[0].FileName).ToLower(), out FileType fileTpye);
+        //    string type = "";
+        //    if (fileTpye != null)
+        //    {
+        //        type = fileTpye.Type;
+        //    }
+
+        //    List<AzureBlobModel> list = await _azureBlobDBRepository.UploadFiles(files);
+        //    await azureTableDBRepository.SaveAll<AzureBlobModel>(list);
+        //    return responseBuilder.Data(list).build();
+        //}
+        //[HttpPost("uploadFile")]
+        //[RequestSizeLimit(204_800_000_00)] //最大20000m左右
+        //public async Task<BaseResponse> BlobSaveFile([FromForm] IFormFile file)
+        //{
+        //    //IFormFileCollection s =  Request.Form.Files;
+        //    ResponseBuilder responseBuilder = new ResponseBuilder();
+        //    FileTypeMap fileTypeMap = new FileTypeMap();
+        //    fileTypeMap.GetFileTypes().TryGetValue(FileType.GetExtention(file.FileName).ToLower(), out FileType fileTpye);
+        //    string type = "";
+        //    if (fileTpye != null)
+        //    {
+        //        type = fileTpye.Type;
+        //    }
+        //    List<IFormFile> files = new List<IFormFile>();
+        //    files.Add(file);
+        //    List<AzureBlobModel> list = await _azureBlobDBRepository.UploadFiles(files.ToArray());
+        //    await azureTableDBRepository.SaveAll<AzureBlobModel>(list);
+        //    return responseBuilder.Data(list).build();
+        //}
        
-        [HttpPost("uploadWangEditor")]
-        [RequestSizeLimit(102_400_000_00)] //最大10000m左右
-        public async Task<Dictionary<string, Object>> uploadWangEditor([FromForm] IFormFile[] files)
-        {
-            //IFormFileCollection s =  Request.Form.Files;
-            ResponseBuilder responseBuilder = new ResponseBuilder();
-            FileTypeMap fileTypeMap = new FileTypeMap();
-            fileTypeMap.GetFileTypes().TryGetValue(FileType.GetExtention(files[0].FileName).ToLower(), out FileType fileTpye);
-            string type = "";
-            if (fileTpye != null)
-            {
-                type = fileTpye.Type;
-            }
-            List<AzureBlobModel> list = await _azureBlobDBRepository.UploadFiles(files.ToArray());
-            await azureTableDBRepository.SaveAll<AzureBlobModel>(list);
-            return new Dictionary<string, object> { { "errno", 0 }, { "data", list.Select(x => x.BlobUrl) } };
-        }
+        //[HttpPost("uploadWangEditor")]
+        //[RequestSizeLimit(102_400_000_00)] //最大10000m左右
+        //public async Task<Dictionary<string, Object>> uploadWangEditor([FromForm] IFormFile[] files)
+        //{
+        //    //IFormFileCollection s =  Request.Form.Files;
+        //    ResponseBuilder responseBuilder = new ResponseBuilder();
+        //    FileTypeMap fileTypeMap = new FileTypeMap();
+        //    fileTypeMap.GetFileTypes().TryGetValue(FileType.GetExtention(files[0].FileName).ToLower(), out FileType fileTpye);
+        //    string type = "";
+        //    if (fileTpye != null)
+        //    {
+        //        type = fileTpye.Type;
+        //    }
+        //    List<AzureBlobModel> list = await _azureBlobDBRepository.UploadFiles(files.ToArray());
+        //    await azureTableDBRepository.SaveAll<AzureBlobModel>(list);
+        //    return new Dictionary<string, object> { { "errno", 0 }, { "data", list.Select(x => x.BlobUrl) } };
+        //}