using Azure.Storage.Blobs.Specialized; using HTEXScreen.Service; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using PuppeteerSharp; using PuppeteerSharp.Media; using System.Configuration; using System.Drawing; using System.IO; using System.Net; using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Web; using TEAMModelOS.SDK; using TEAMModelOS.SDK.DI; namespace HTEXScreen.Controllers { [ApiController] [Route("api")] public class IndexController : ControllerBase { private readonly AzureStorageFactory _azureStorage; private readonly HttpClient _httpClient; private readonly IConfiguration _configuration; // private readonly HttpContext _httpContext; public IndexController(HttpClient httpClient, AzureStorageFactory azureStorage, IConfiguration configuration) { _httpClient = httpClient; _azureStorage = azureStorage; _configuration = configuration; // _httpContext=httpContext; } /// /// 上传到blob /// /// /// [HttpPost("http-log")] [RequestSizeLimit(102_400_000_00)] //最大10000m左右 public async Task HttpLog(JsonElement json) { string data = json.ToJsonString(); var gmt8Time = DateTimeOffset.Now.GetGMTTime(8); var appendBlob = _azureStorage.GetBlobContainerClient("0-service-log").GetAppendBlobClient($"http-log/{gmt8Time:yyyy}/{gmt8Time:MM}/{gmt8Time:dd}/{gmt8Time:HH}.log"); if (!appendBlob.Exists()) { await appendBlob.CreateAsync(); using var stream = new MemoryStream(Encoding.UTF8.GetBytes($"{data},\n")); _= appendBlob.AppendBlockAsync(stream); } else { using var stream = new MemoryStream(Encoding.UTF8.GetBytes($"{data},\n")); _= appendBlob.AppendBlockAsync(stream); } return Ok(new { code=1}); } } }