Added FileUtilities for user uploaded files
This commit is contained in:
parent
e3e66cda22
commit
7b636a28df
15
Wave/Utilities/FileUtilities.cs
Normal file
15
Wave/Utilities/FileUtilities.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue