Пример #1
0
        private bool CheckIfImageFile(IFormFile file)
        {
            byte[] fileBytes;
            using (var ms = new MemoryStream())
            {
                file.CopyTo(ms);
                fileBytes = ms.ToArray();
            }

            return(WriteHelper.GetImageFormat(fileBytes) != WriteHelper.ImageFormat.unknown);
        }
Пример #2
0
        // ensure that the file is an image
        private bool CheckIfImageFile(IFormFile file)
        {
            byte[] fileBytes;
            using (var ms = new MemoryStream())
            {
                file?.CopyTo(ms);
                fileBytes = ms.ToArray();
            }
            // Convert byte[] to Base64 String
            //string base64String = Convert.ToBase64String(fileBytes);

            return(WriteHelper.GetImageFormat(fileBytes) != WriteHelper.ImageFormat.unknown);
        }