Initial commit
This commit is contained in:
commit
77d35ff965
51 changed files with 5591 additions and 0 deletions
57
Pages/Azure/Container.cshtml.cs
Normal file
57
Pages/Azure/Container.cshtml.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using PlanTempusAdmin.Models;
|
||||
using PlanTempusAdmin.Services;
|
||||
|
||||
namespace PlanTempusAdmin.Pages.Azure;
|
||||
|
||||
public class ContainerModel : PageModel
|
||||
{
|
||||
private readonly AzureStorageService _azureService;
|
||||
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string? Prefix { get; set; }
|
||||
|
||||
public ContainerDetails Details { get; set; } = new();
|
||||
public bool IsConnected { get; set; }
|
||||
|
||||
public ContainerModel(AzureStorageService azureService)
|
||||
{
|
||||
_azureService = azureService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
{
|
||||
return RedirectToPage("/Azure/Index");
|
||||
}
|
||||
|
||||
IsConnected = await _azureService.TestConnectionAsync();
|
||||
if (IsConnected)
|
||||
{
|
||||
Details = await _azureService.GetContainerDetailsAsync(Name, Prefix, limit: 200);
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostDeleteAsync(string container, string blob)
|
||||
{
|
||||
await _azureService.DeleteBlobAsync(container, blob);
|
||||
return RedirectToPage(new { name = container, prefix = Prefix });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetDownloadAsync(string container, string blob)
|
||||
{
|
||||
var url = await _azureService.GetBlobDownloadUrlAsync(container, blob);
|
||||
if (url == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Redirect(url);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue