|
@@ -14,6 +14,7 @@ using TEAMModelOS.SDK.DI;
|
|
|
using System.Net.Http;
|
|
|
using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
+using System.IdentityModel.Tokens.Jwt;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Core
|
|
|
{
|
|
@@ -39,8 +40,7 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
[HttpPost("sas-r")]
|
|
|
public IActionResult BlobSasR(BlobSas request)
|
|
|
{
|
|
|
- ///返回金钥过期时间
|
|
|
- ResponseBuilder builder = new ResponseBuilder();
|
|
|
+ ///返回金钥过期时间
|
|
|
// Dictionary<string, object> dict = await azureBlobDBRepository.GetBlobSasUri(request.@params,true);
|
|
|
// dict.Add(d.Key, d.Value);
|
|
|
return Ok(_azureStorage.GetContainerSasUri(request, true));
|
|
@@ -54,12 +54,92 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
public IActionResult BlobSasRCW(BlobSas request)
|
|
|
{
|
|
|
///返回金钥过期时间
|
|
|
- ResponseBuilder builder = new ResponseBuilder();
|
|
|
// Dictionary<string,object> dict= await azureBlobDBRepository.GetBlobSasUri(request.@params,false);
|
|
|
// Dictionary<string, object> dict = ;
|
|
|
//dict.Add(d.Key, d.Value);
|
|
|
return Ok(_azureStorage.GetContainerSasUri(request, false));
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除prefix
|
|
|
+ ///
|
|
|
+ /// {"cntr":"","prefix":"res/test"}
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("delete-prefix")]
|
|
|
+ public async Task<IActionResult> DeletePrefix(JsonElement json)
|
|
|
+ {
|
|
|
+ var (id,_,_,school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ string blobContainerName = null;
|
|
|
+ string prefix = null;
|
|
|
+ if (json.TryGetProperty("cntr", out JsonElement cntr)) {
|
|
|
+ var cntrs= cntr.ToString();
|
|
|
+
|
|
|
+ if (cntrs.Equals(id))
|
|
|
+ {
|
|
|
+ blobContainerName = id;
|
|
|
+ }
|
|
|
+ else if(cntrs.Equals(school))
|
|
|
+ {
|
|
|
+ blobContainerName = school;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (json.TryGetProperty("prefix", out JsonElement prefixjson))
|
|
|
+ {
|
|
|
+ prefix = prefixjson.ToString();
|
|
|
+ }
|
|
|
+ if (prefix != null && blobContainerName != null)
|
|
|
+ {
|
|
|
+ var status = await _azureStorage.GetBlobServiceClient().DelectBlobs(blobContainerName, prefix);
|
|
|
+ return Ok(new { status });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除多个Url
|
|
|
+ ///
|
|
|
+ /// {"cntr":"","urls":["res/test/1.json","res/test/2.json"]}
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("delete-blobs")]
|
|
|
+ public async Task<IActionResult> DeleteBlobs(JsonElement json)
|
|
|
+ {
|
|
|
+ var (id, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ string blobContainerName = null;
|
|
|
+ List<Uri> uris = null;
|
|
|
+ if (json.TryGetProperty("cntr", out JsonElement cntr))
|
|
|
+ {
|
|
|
+ var cntrs = cntr.ToString();
|
|
|
+
|
|
|
+ if (cntrs.Equals(id))
|
|
|
+ {
|
|
|
+ blobContainerName = id;
|
|
|
+ }
|
|
|
+ else if (cntrs.Equals(school))
|
|
|
+ {
|
|
|
+ blobContainerName = school;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (json.TryGetProperty("urls", out JsonElement urlsjson)) {
|
|
|
+ uris= urlsjson.ToObject<List<Uri>>();
|
|
|
+ }
|
|
|
+ if (blobContainerName != null && uris != null && uris.Count > 0)
|
|
|
+ {
|
|
|
+ var status = await _azureStorage.GetBlobServiceClient().DelectBlobs("", new List<Uri>());
|
|
|
+ return Ok(new { });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 链接只读(读)
|
|
|
/// </summary>
|
|
@@ -68,7 +148,6 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
[HttpPost("sas-url-r")]
|
|
|
public IActionResult GetContainerSASRead(JsonElement azureBlobSASDto)
|
|
|
{
|
|
|
- ResponseBuilder responseBuilder = new ResponseBuilder();
|
|
|
azureBlobSASDto.TryGetProperty("url", out JsonElement azureBlobSAS);
|
|
|
//string azureBlobSAS = azureBlobSASDto;
|
|
|
(string, string) a = BlobUrlString(azureBlobSAS.ToString());
|
|
@@ -95,8 +174,7 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
[HttpPost("get-text")]
|
|
|
public async Task<IActionResult> GetText(JsonElement request)
|
|
|
{
|
|
|
- request.TryGetProperty("code", out JsonElement code);
|
|
|
- ResponseBuilder responseBuilder = new ResponseBuilder();
|
|
|
+ request.TryGetProperty("code", out JsonElement code);
|
|
|
string azureBlobSAS = System.Web.HttpUtility.UrlDecode(code.ToString(), Encoding.UTF8);
|
|
|
(string, string) a = BlobUrlString(azureBlobSAS);
|
|
|
string ContainerName = a.Item1;
|
|
@@ -117,7 +195,7 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
};
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 测试单个文本内容的上传
|
|
|
/// </summary>
|