|
@@ -18,6 +18,8 @@ using Microsoft.AspNetCore.Authorization;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
using StackExchange.Redis;
|
|
using StackExchange.Redis;
|
|
using Azure.Messaging.ServiceBus;
|
|
using Azure.Messaging.ServiceBus;
|
|
|
|
+using static TEAMModelOS.SDK.DI.AzureStorageBlobExtensions;
|
|
|
|
+using System.Linq;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Core
|
|
namespace TEAMModelOS.Controllers.Core
|
|
{
|
|
{
|
|
@@ -235,7 +237,6 @@ namespace TEAMModelOS.Controllers.Core
|
|
[HttpPost("get-blobsize")]
|
|
[HttpPost("get-blobsize")]
|
|
public async Task<ActionResult> GetBlobsSize(JsonElement request)
|
|
public async Task<ActionResult> GetBlobsSize(JsonElement request)
|
|
{
|
|
{
|
|
-
|
|
|
|
request.TryGetProperty("containerName", out JsonElement containerName);
|
|
request.TryGetProperty("containerName", out JsonElement containerName);
|
|
request.TryGetProperty("cache", out JsonElement cache);
|
|
request.TryGetProperty("cache", out JsonElement cache);
|
|
var name =containerName.GetString();
|
|
var name =containerName.GetString();
|
|
@@ -259,24 +260,43 @@ namespace TEAMModelOS.Controllers.Core
|
|
{
|
|
{
|
|
foreach (var score in Scores) {
|
|
foreach (var score in Scores) {
|
|
double val = score.Score;
|
|
double val = score.Score;
|
|
- // string key= score.Element
|
|
|
|
|
|
+ string key = score.Element.ToString();
|
|
|
|
+ catalog.Add(key, val);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return Ok(new { size = blobsize });
|
|
|
|
|
|
+ return Ok(new { size = blobsize, catalog= catalog });
|
|
}
|
|
}
|
|
} catch { }
|
|
} catch { }
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var size = await client.GetBlobsCatalogSize();
|
|
var size = await client.GetBlobsCatalogSize();
|
|
-
|
|
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size.Item1);
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size.Item1);
|
|
foreach (var key in size.Item2.Keys) {
|
|
foreach (var key in size.Item2.Keys) {
|
|
await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", key, size.Item2[key].HasValue?size.Item2[key].Value:0);
|
|
await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{name}", key, size.Item2[key].HasValue?size.Item2[key].Value:0);
|
|
}
|
|
}
|
|
return Ok(new { size = size.Item1, catalog = size.Item2 });
|
|
return Ok(new { size = size.Item1, catalog = size.Item2 });
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 测试单个文本内容的上传
|
|
|
|
+ /// {"containerName":"hbcn","urls":["video/xxx.mp4","res/xxx.png"]}
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="azureBlobSASDto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("check-blobsize")]
|
|
|
|
+ public async Task<ActionResult> checkBlobsSize(JsonElement request)
|
|
|
|
+ {
|
|
|
|
+ request.TryGetProperty("containerName", out JsonElement containerName);
|
|
|
|
+ request.TryGetProperty("urls", out JsonElement optUrls);
|
|
|
|
+ var name = containerName.GetString();
|
|
|
|
+ var urls = optUrls.ToObject<List<string>>();
|
|
|
|
+ var client = _azureStorage.GetBlobContainerClient(name);
|
|
|
|
+ var urlsSize = await client.GetBlobsSize(urls);
|
|
|
|
+ return Ok(new { urlsSize });
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 测试单个文本内容的上传
|
|
/// 测试单个文本内容的上传
|
|
- /// {"containerName":"hbcn","uploadSize":5000,"optUrls":[]}
|
|
|
|
|
|
+ /// {"containerName":"hbcn","uploadSize":5000,"optUrls":[{"url":"video/37Z888piCvm9.mp4","size":0},{}]}
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="azureBlobSASDto"></param>
|
|
/// <param name="azureBlobSASDto"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
@@ -285,13 +305,10 @@ namespace TEAMModelOS.Controllers.Core
|
|
{
|
|
{
|
|
request.TryGetProperty("containerName", out JsonElement containerName);
|
|
request.TryGetProperty("containerName", out JsonElement containerName);
|
|
request.TryGetProperty("optUrls", out JsonElement optUrls);
|
|
request.TryGetProperty("optUrls", out JsonElement optUrls);
|
|
- request.TryGetProperty("uploadSize", out JsonElement uploadSize);
|
|
|
|
var name = containerName.GetString();
|
|
var name = containerName.GetString();
|
|
- uploadSize.TryGetInt64(out long size);
|
|
|
|
- var urls = optUrls.ToObject<List<string>>();
|
|
|
|
|
|
+ var urls = optUrls.ToObject<List<OptUrl>>();
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
- var urlsSize = await client.GetBlobsSize(urls);
|
|
|
|
- long? disSize= size - urlsSize;
|
|
|
|
|
|
+ var disSize = urls.Select(x => x.size).Sum();
|
|
RedisValue value = default;
|
|
RedisValue value = default;
|
|
long? useSize = 0;
|
|
long? useSize = 0;
|
|
long blobSize = 0;
|
|
long blobSize = 0;
|
|
@@ -299,9 +316,8 @@ namespace TEAMModelOS.Controllers.Core
|
|
if (value != default && !value.IsNullOrEmpty)
|
|
if (value != default && !value.IsNullOrEmpty)
|
|
{
|
|
{
|
|
JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
- if (record.TryGetInt64(out blobSize))
|
|
|
|
|
|
+ if (record.TryGetInt64(out blobSize))
|
|
{
|
|
{
|
|
- useSize = blobSize;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
useSize = useSize + disSize;
|
|
useSize = useSize + disSize;
|