Skip to content

Commit

Permalink
feat: always store file to fs
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Oct 6, 2023
1 parent 099f8d4 commit 3f1132b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/GZCTF/Repositories/FileRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ async Task<LocalFile> StoreLocalFile(string fileName, Stream contentStream, Canc
{
localFile = new() { Hash = fileHash, Name = fileName, FileSize = contentStream.Length };
await context.AddAsync(localFile, token);
}

var path = Path.Combine(FilePath.Uploads, localFile.Location);
var path = Path.Combine(FilePath.Uploads, localFile.Location);

if (!Directory.Exists(path))
Directory.CreateDirectory(path);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);

using FileStream fileStream = File.Create(Path.Combine(path, localFile.Hash));
using FileStream fileStream = File.Create(Path.Combine(path, localFile.Hash));

contentStream.Position = 0;
await contentStream.CopyToAsync(fileStream, token);
}
contentStream.Position = 0;
await contentStream.CopyToAsync(fileStream, token);

await SaveAsync(token);
return localFile;
}
}
}

0 comments on commit 3f1132b

Please sign in to comment.