private string DownloadVerficationImg(string workingRootPath, ValidationData validationData) { var saveToFilePath = folderHandler.CreateFolder(workingRootPath, "validation").FullName + Path.DirectorySeparatorChar + "arcValidation.png"; folderHandler.SaveImageFromUri(workingRootPath, saveToFilePath, ImageFormat.Png, "https://icinfo.immigration.gov.tw/NIL_WEB/ValidateCode.ashx", "ASP.NET_SessionId", validationData.SessionId); return(saveToFilePath); }
public async Task <string> SavePic(UserArc userArc, byte imageType, IFormFile image) { string mainFolder = imageType switch { 0 => ((PictureTypeEnum)imageType).ToString().ToLower(), 1 => ((PictureTypeEnum)imageType).ToString().ToLower(), 2 => ((PictureTypeEnum)imageType).ToString().ToLower(), 3 => ((PictureTypeEnum)imageType).ToString().ToLower(), _ => PictureTypeEnum.Other.ToString().ToLower(), }; string resultFileName = imageType + "_" + userArc.ArcNo + "_" + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); string folder = mainFolder + Path.DirectorySeparatorChar + userArc.UserId; DirectoryInfo directoryInfo = folderHandler.CreateFolder(workingRootPath, folder); var filePath = Path.Combine(directoryInfo.FullName, resultFileName); using (var stream = System.IO.File.Create(filePath)) { await image.CopyToAsync(stream); } return(resultFileName); }