CrazyIter_Bin il y a 4 ans
Parent
commit
e5a52e0b20

+ 4 - 36
TEAMModelOS.SDK/DI/AzureStorage/AzureStorageBlobExtensions.cs

@@ -103,7 +103,6 @@ namespace TEAMModelOS.SDK.DI
             BlobContainerClient blobContainer = azureStorage.GetBlobContainerClient(name.ToLower().Replace("#", "")); //blobClient.GetContainerReference(groupName);            
 
             var blockBlob = blobContainer.GetBlobClient($"{root}/{blobpath}");
-            
             string content_type = "application/octet-stream";
             if (!contentTypeDefault)
             {
@@ -113,16 +112,6 @@ namespace TEAMModelOS.SDK.DI
                 {
                     content_type = contenttype;
                 }
-                else
-                {
-
-                    //blockBlob.Properties.ContentType = content_type;
-                }
-            }
-            else
-            {
-
-                //blockBlob.Properties.ContentType = content_type;
             }
             byte[] bytes = System.Text.Encoding.Default.GetBytes(json);
             Stream streamBlob = new MemoryStream(bytes);
@@ -148,45 +137,24 @@ namespace TEAMModelOS.SDK.DI
         /// <param name="fileName">文件名</param>
         /// <param name="contentTypeDefault">是否存放文件后缀对应的contentType</param>
         /// <returns></returns>
-        public static async Task<AzureBlobModel> UploadFileByContainer(this AzureStorageFactory azureStorage, string name, Stream stream, string folder, string fileName, bool contentTypeDefault = true)
+        public static async Task<string> UploadFileByContainer(this AzureStorageFactory azureStorage, string name, Stream stream, string root, string blobpath, bool contentTypeDefault = true)
         {
-
-            // string groupName =folder;
-
             BlobContainerClient blobContainer = azureStorage.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);
+            var blockBlob = blobContainer.GetBlobClient($"{root}/{blobpath}");
             string content_type = "application/octet-stream";
             if (!contentTypeDefault)
             {
+                string fileext = blobpath.Substring(blobpath.LastIndexOf(".") > 0 ? blobpath.LastIndexOf(".") : 0);
                 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;
-            }
             await blockBlob.UploadAsync(stream, true);
             blockBlob.SetHttpHeaders(new BlobHttpHeaders { ContentType = content_type });
-            AzureBlobModel model = new AzureBlobModel(fileName, name, folder, fileName, folder, content_type, stream.Length)
-            {
-                Sha1Code = ShaHashHelper.GetSHA1(stream),
-                BlobUrl = blockBlob.Uri.ToString()
-            };
-            return model;
+            return blockBlob.Uri.ToString();
         }
     }
 }

+ 3 - 3
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -2,9 +2,9 @@
 
   <PropertyGroup>
     <TargetFramework>netcoreapp3.1</TargetFramework>
-    <Version>3.0.1211</Version>
-    <AssemblyVersion>3.0.1211.0</AssemblyVersion>
-    <FileVersion>3.0.1211.0</FileVersion>
+    <Version>3.0.1217</Version>
+    <AssemblyVersion>3.0.1217.0</AssemblyVersion>
+    <FileVersion>3.0.1217.0</FileVersion>
     <PackageReleaseNotes>520发版</PackageReleaseNotes>
   </PropertyGroup>