public string GetFile([FromBody] UploadedImg img)
        {
            // Create unique file name
            string photoId = Guid.NewGuid().ToString();
            //string filePath = @"ClientApp\src\assets\Post\" + photoId + ".jpg";
            string filePathDetail = "Photo/" + photoId + ".jpg";
            string filePath       = @"wwwroot\Photo\" + photoId + ".jpg";

            // Remove file type from base64 encoding, if any
            if (img.FileAsBase64.Contains(","))
            {
                img.FileAsBase64 = img.FileAsBase64
                                   .Substring(img.FileAsBase64.IndexOf(",") + 1);
            }

            // Convert base64 encoded string to binary
            img.FileAsByteArray = Convert.FromBase64String(img.FileAsBase64);

            // Write binary file to server path
            using (var fs = new FileStream(filePath, FileMode.CreateNew))
            {
                fs.Write(img.FileAsByteArray, 0, img.FileAsByteArray.Length);
            }
            return(filePathDetail);
        }
        public async Task <IActionResult> GetFile([FromBody] UploadedImg img, int id)
        {
            // Create unique file name
            string photoId = Guid.NewGuid().ToString();
            //string filePath = @"ClientApp\src\assets\Post\" + photoId + ".jpg";
            string filePathDetail = "Photo/" + photoId + ".jpg";
            string filePath       = @"wwwroot\Photo\" + photoId + ".jpg";

            // Remove file type from base64 encoding, if any
            if (img.FileAsBase64.Contains(","))
            {
                img.FileAsBase64 = img.FileAsBase64
                                   .Substring(img.FileAsBase64.IndexOf(",") + 1);
            }

            // Convert base64 encoded string to binary
            img.FileAsByteArray = Convert.FromBase64String(img.FileAsBase64);

            // Write binary file to server path
            using (var fs = new FileStream(filePath, FileMode.CreateNew))
            {
                fs.Write(img.FileAsByteArray, 0, img.FileAsByteArray.Length);
            }
            ImgPath imgPath = new ImgPath();

            imgPath.Path    = filePathDetail;
            imgPath.AlbumID = id;
            _context.ImgPaths.Add(imgPath);
            _context.SaveChanges();
            await Task.CompletedTask;

            return(new OkObjectResult(filePathDetail));
        }
        public IActionResult GetFile([FromBody] UploadedImg img, int id)
        {
            // Create unique file name
            string photoId = Guid.NewGuid().ToString();
            //string filePath = @"ClientApp\src\assets\Post\" + photoId + ".jpg";
            string filePath = @"wwwroot\Photo\" + photoId + ".jpg";

            // Remove file type from base64 encoding, if any
            if (img.FileAsBase64.Contains(","))
            {
                img.FileAsBase64 = img.FileAsBase64
                                   .Substring(img.FileAsBase64.IndexOf(",") + 1);
            }

            // Convert base64 encoded string to binary
            img.FileAsByteArray = Convert.FromBase64String(img.FileAsBase64);

            // Write binary file to server path
            using (var fs = new FileStream(filePath, FileMode.CreateNew))
            {
                fs.Write(img.FileAsByteArray, 0, img.FileAsByteArray.Length);
            }
            var entity = _context.Album.FirstOrDefault(s => s.ID == id);

            if (entity == null)
            {
                return(new BadRequestResult());
            }
            ImgPath path = new ImgPath();

            path.Path = filePath;
            entity.ImgPaths.Add(path);
            _context.Entry(entity).CurrentValues.SetValues(entity);
            _context.SaveChanges();
            return(new OkObjectResult("Photo/" + photoId + ".jpg"));
        }