Added FileUtilities for user uploaded files

This commit is contained in:
Mia Rose Winter 2024-01-14 13:00:16 +01:00
parent e3e66cda22
commit 7b636a28df
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -0,0 +1,15 @@
namespace Wave.Utilities;
public static class FileUtilities {
public static async Task<string> StoreTemporary(Stream fileStream) {
string tempName = Path.GetRandomFileName();
string tempDirectory = Path.Combine(".", "files", "temp");
Directory.CreateDirectory(tempDirectory);
string tempPath = Path.Combine(tempDirectory, tempName);
await using var fs = new FileStream(tempPath, FileMode.Create);
await fileStream.CopyToAsync(fs);
return tempPath;
}
}