Browse Source

Merge branch 'develop3.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0-tmd

OnePsycho 4 years ago
parent
commit
79c842e504
1 changed files with 19 additions and 2 deletions
  1. 19 2
      TEAMModelOS/Controllers/Core/ImportController.cs

+ 19 - 2
TEAMModelOS/Controllers/Core/ImportController.cs

@@ -71,7 +71,24 @@ namespace TEAMModelOS.Controllers
             string text = builder.ToString();
             langConfigs = text.ToObject<List<LangConfig>>();
         }
+        private static string ReplaceLast(string input, string oldValue, string newValue)
+        {
+            int index = input.LastIndexOf(oldValue);
+            if (index < 0)
+            {
+                return input;
+            }
+            else
+            {
+                StringBuilder sb = new StringBuilder(input.Length - oldValue.Length + newValue.Length);
+                sb.Append(input.Substring(0, index));
+                sb.Append(newValue);
+                sb.Append(input.Substring(index + oldValue.Length,
+                   input.Length - index - oldValue.Length));
 
+                return sb.ToString();
+            }
+        }
 
         /// <summary>
         ///  {"file":"www....xxxx.pptx","scope":"private/school"}
@@ -105,8 +122,8 @@ namespace TEAMModelOS.Controllers
             bool flg = IsBlobName(BlobName);
             var codes = azureBlobSAS.Split("/");
             var file = codes[codes.Length - 1].Split(".");
-            var FileName = file[0];
-            var ext = file[1];
+            var ext = file[file.Length - 1];
+            var FileName = ReplaceLast(codes[codes.Length - 1], "." + ext, "");
             if (flg)
             {
                 BlobAuth blobAuth = _azureStorage.GetBlobSasUriRead(ContainerName, BlobName);