/// <summary> /// Create the specified file. /// </summary> /// <returns>The create.</returns> /// <param name="file">File.</param> public static LocalFile Create(IFormFile file) { // get unique file name string newPath = Guid.NewGuid() + Path.GetExtension(file.FileName); LocalFile localFile = new LocalFile() { LocalPath = newPath, Stream = file.OpenReadStream() }; return(localFile); }
/// <summary> /// Create the specified file. /// </summary> /// <returns>The create.</returns> /// <param name="file">File.</param> public static async Task <LocalFile> Create(IFormFile file) { // get unique file name string newPath = TempPath + Guid.NewGuid() + Path.GetExtension(file.FileName); using (FileStream stream = new FileStream(newPath, FileMode.Create)) { await file.CopyToAsync(stream); } LocalFile localFile = new LocalFile() { LocalPath = newPath }; return(localFile); }