Exemple #1
0
        // Write the file to storage
        private static async Task <UploadModel> WriteFile(this IFormFile file, string uploadUrl)
        {
            if (!Directory.Exists(uploadUrl))
            {
                Directory.CreateDirectory(uploadUrl);
            }

            var upload = await file.CreateUploadModel(uploadUrl);

            using (var stream = new FileStream(upload.Path, FileMode.Create))
            {
                await file.CopyToAsync(stream);
            }
            return(upload);
        }