static async Task <Upload> WriteFile(this IFormFile file, string path, string url) { if (!(Directory.Exists(path))) { Directory.CreateDirectory(path); } var upload = await file.CreateUpload(path, url); using (var stream = new FileStream(upload.Path, FileMode.Create)) { await file.CopyToAsync(stream); } return(upload); }