Files
caliverse_server/UGQApiServer/UGQData/UGQBannerImageList.cs
2025-05-01 07:20:41 +09:00

43 lines
971 B
C#

using System.Text;
using System.Text.Json;
using System.Collections.Generic;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Options;
using Amazon.S3;
using MetaAssets;
using UGQApiServer.Models;
using UGQApiServer.Settings;
using UGQApiServer.Storage;
using UGQDatabase.Models;
using UGQDataAccess.Settings;
namespace UGQApiServer.UGQData;
public class UGQBannerImageList
{
readonly AmazonS3Client _s3Client;
readonly S3Settings _settings;
public UGQBannerImageList(IOptions<S3Settings> settings)
{
_settings = settings.Value;
_s3Client = new AmazonS3Client(_settings.AccessKey, _settings.SecretAccessKey, Amazon.RegionEndpoint.USEast1);
}
public async Task<List<string>> getFiles()
{
var res = await _s3Client.ListObjectsAsync(_settings.BucketName, "preset");
return res.S3Objects.Where(x => x.Key.EndsWith(".png"))
.Select(x => x.Key).ToList();
}
}