网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
using Dpz.Core.Infrastructure.PublicStruct;
using Dpz.Core.Shard.Service;

namespace Dpz.Core.Service.ObjectStorage.Services.Impl;

public class CloudFileService(IObjectStorageOperation objectStorageService) : ICloudFileService
{
    public async Task<FileAddress?> UploadFileAsync(CloudFile file)
    {
        return await objectStorageService.UploadFileAsync(file);
    }

    public async Task<List<FileAddress>?> UploadFilesAsync(params CloudFile[] files)
    {
        return await UploadFilesAsync((ICollection<CloudFile>)files);
    }

    public async Task<List<FileAddress>?> UploadFilesAsync(ICollection<CloudFile> files)
    {
        var addresses = new List<FileAddress>();
        await Parallel.ForEachAsync(files, async (x, _) =>
        {
            var address = await objectStorageService.UploadFileAsync(x);
            if (address.HasValue)
            {
                addresses.Add(address.Value);
            }
        });
        return addresses;
    }

    public async Task DeleteAsync(params string[] pathToFile)
    {
        var url = string.Join("/", pathToFile.Select(Uri.EscapeDataString));
        await objectStorageService.DeleteAsync(url);
    }
}
loading