public void IsStringTest()
        {
            var    a          = "renato".ToBase64();
            string sourcePath = "..\\..\\filestest\\input";
            var    a2         = File.OpenRead($"{sourcePath}\\SQLQuery1.sql");
            string s          = Base64Converter.ToBase64String(a2);

            var t = FinderMimeType.IsString(Convert.FromBase64String(a));

            t = FinderMimeType.IsString(Convert.FromBase64String(s));
        }
Exemple #2
0
        /// <summary>
        /// Decodifica o base64 para o objeto desejado
        /// </summary>
        /// <param name="input">String base64</param>
        /// <param name="mime">Tipo de objeto resultante da Decodificação</param>
        /// <returns>Objeto decodificado</returns>
        public static object FromBase64Object(string input, out IMimeType mime)
        {
            if (string.IsNullOrEmpty(input))
            {
                throw new ArgumentException("message", nameof(input));
            }

            byte[] result = Convert.FromBase64String(input);

            if (FinderMimeType.IsString(result))
            {
                mime = new MimeType("#string#", "", null);
                return(Encoding.UTF8.GetString(result));
            }
            else
            {
                var          _mime = FinderMimeType.GetMimeType(result);
                MemoryStream m     = new MemoryStream(result);
                mime = _mime;
                return(m);
            }
        }