14 lines
541 B
C#
14 lines
541 B
C#
namespace ForgejoReleaseSync.Services;
|
|
|
|
public class ReleaseAssetDownloadService(HttpClient httpClient)
|
|
{
|
|
public async Task<string> DownloadReleaseAssetAsync(Uri url)
|
|
{
|
|
var fileName = Path.GetFileName(url.AbsoluteUri);
|
|
var filePath = Path.Combine(Path.GetTempPath(), fileName);
|
|
await using Stream resource = await httpClient.GetStreamAsync(url);
|
|
await using FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
|
|
await resource.CopyToAsync(fs, 8192);
|
|
return filePath;
|
|
}
|
|
} |