|
@@ -16,6 +16,7 @@ using TEAMModelOS.SDK.Extension;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
|
|
+using StackExchange.Redis;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Core
|
|
namespace TEAMModelOS.Controllers.Core
|
|
{
|
|
{
|
|
@@ -26,11 +27,14 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
|
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
private readonly IHttpClientFactory _clientFactory;
|
|
private readonly IHttpClientFactory _clientFactory;
|
|
-
|
|
|
|
- public BlobController(AzureStorageFactory azureStorage, IHttpClientFactory clientFactory)
|
|
|
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
|
+ private readonly AzureServiceBusFactory _serviceBus;
|
|
|
|
+ public BlobController(AzureStorageFactory azureStorage, AzureServiceBusFactory serviceBus, IHttpClientFactory clientFactory, AzureRedisFactory azureRedis)
|
|
{
|
|
{
|
|
_azureStorage = azureStorage;
|
|
_azureStorage = azureStorage;
|
|
_clientFactory = clientFactory;
|
|
_clientFactory = clientFactory;
|
|
|
|
+ _serviceBus = serviceBus;
|
|
|
|
+ _azureRedis = azureRedis;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -230,8 +234,34 @@ 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);
|
|
var name =containerName.GetString();
|
|
var name =containerName.GetString();
|
|
|
|
+ RedisValue value = default;
|
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", name);
|
|
|
|
+ if (value != default && !value.IsNullOrEmpty)
|
|
|
|
+ {
|
|
|
|
+ JsonElement record = value.ToString().ToObject<JsonElement>();
|
|
|
|
+ if (record.TryGetInt64(out long blobsize))
|
|
|
|
+ {
|
|
|
|
+ return Ok(new { size= blobsize });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var client = _azureStorage.GetBlobContainerClient(name);
|
|
|
|
+ var size = await client.GetBlobsSize();
|
|
|
|
+ await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", name, size);
|
|
|
|
+ return Ok(new { size });
|
|
|
|
+ }
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 测试单个文本内容的上传
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="azureBlobSASDto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("update-blobsize")]
|
|
|
|
+ public async Task<ActionResult> updateBlobsSize(JsonElement request)
|
|
|
|
+ {
|
|
|
|
+ request.TryGetProperty("containerName", out JsonElement containerName);
|
|
|
|
+ var name = containerName.GetString();
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var client = _azureStorage.GetBlobContainerClient(name);
|
|
var size = await client.GetBlobsSize();
|
|
var size = await client.GetBlobsSize();
|
|
return Ok(new { size });
|
|
return Ok(new { size });
|