public async Task <string> WriteFileByte(byte[] file)
        {
            string fileName;
            var    folder = "images/";

            try
            {
                var extension = WriterHelper.GetFileExtension(file);
                var stream    = new MemoryStream(file);
                fileName = Guid.NewGuid().ToString() + extension;
                //IFormFile ImageFile = new FormFile(stream, 0, file.Length, "ImageFile", fileName);

                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images", fileName);

                if (extension == ".pdf" ||
                    extension == ".doc" ||
                    extension == ".docx")
                {
                    path   = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\documents", fileName);
                    folder = "documents/";
                }

                using (var bits = new FileStream(path, FileMode.Create))
                {
                    await bits.WriteAsync(file, 0, file.Length);
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }

            return(fileName);
            //return ApiRoutes.Domain + folder + fileName;
        }
        private bool CheckIfDocumentFile(IFormFile file)
        {
            byte[] fileBytes;
            using (var ms = new MemoryStream())
            {
                file.CopyTo(ms);
                fileBytes = ms.ToArray();
            }

            return(WriterHelper.GetDocumentFormat(fileBytes) != WriterHelper.DocumentFormat.unknown);
        }
 private bool CheckIfDocumentByteFile(byte[] document)
 {
     return(WriterHelper.GetDocumentFormat(document) != WriterHelper.DocumentFormat.unknown);
 }
 private bool CheckIfImageByteFile(byte[] file)
 {
     return(WriterHelper.GetImageFormat(file) != WriterHelper.ImageFormat.unknown);
 }