diff --git a/ALttPRandomizer/Azure/AzureStorage.cs b/ALttPRandomizer/Azure/AzureStorage.cs index 9906f83..16ff340 100644 --- a/ALttPRandomizer/Azure/AzureStorage.cs +++ b/ALttPRandomizer/Azure/AzureStorage.cs @@ -1,6 +1,5 @@ namespace ALttPRandomizer.Azure { using global::Azure.Storage.Blobs; - using global::Azure.Storage.Blobs.Models; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -64,6 +63,20 @@ return data; } + public async Task GetFile(string filename) { + var blob = this.BlobClient.GetBlobClient(filename); + var exists = await blob.ExistsAsync(); + if (!exists.HasValue || !exists.Value) { + return null; + } + var result = await blob.DownloadContentAsync(); + if (result.HasValue) { + return result.Value.Content; + } else { + return null; + } + } + public async Task GetFileCreation(string filename) { var blob = this.BlobClient.GetBlobClient(filename); var blobProperties = await blob.GetPropertiesAsync(); diff --git a/ALttPRandomizer/SeedController.cs b/ALttPRandomizer/SeedController.cs index 0d27c2d..79fbc1d 100644 --- a/ALttPRandomizer/SeedController.cs +++ b/ALttPRandomizer/SeedController.cs @@ -72,6 +72,19 @@ return ResolveResult(await this.RandomizeService.RetryMulti(id)); } + [Route("/multidata/{id}")] + [HttpGet] + public async Task GetMultidata(string id) { + var multidata = await this.SeedService.GetMultidata(id); + if (multidata == null) { + return NotFound("multidata not found"); + } else { + return new FileContentResult(multidata.ToArray(), "application/octet-stream") { + FileDownloadName = $"{id}_multidata", + }; + } + } + private ActionResult ResolveResult(IDictionary result) { if (result.TryGetValue("status", out var responseCode)) { if (responseCode is int code) { diff --git a/ALttPRandomizer/Service/SeedService.cs b/ALttPRandomizer/Service/SeedService.cs index c04fbf3..2ff1adb 100644 --- a/ALttPRandomizer/Service/SeedService.cs +++ b/ALttPRandomizer/Service/SeedService.cs @@ -127,5 +127,9 @@ return result; } + + public async Task GetMultidata(string multiId) { + return await this.AzureStorage.GetFile($"{multiId}/multidata"); + } } }