MeowStash/Services/FileIOService.cs
2023-03-22 11:32:04 +01:00

23 lines
597 B
C#

namespace MeowStash.Services;
public class FileIOService
{
public async Task WriteFullFile(string location, byte[] data)
{
await File.WriteAllBytesAsync(location, data);
}
public async Task WriteFullFile(string location, Stream data)
{
using var stream = File.OpenWrite(location);
await data.CopyToAsync(stream);
stream.Close();
}
public async Task WritePartialFile(int id, Stream data)
{
using var stream = File.Open($"/tmp/{id}", FileMode.Append);
await data.CopyToAsync(stream);
stream.Close();
}
}