Example #1
0
        public async Task <List <string> > Post(IFormFile file)
        {
            byte[] imagemBytes;
            using (var ms = new MemoryStream())
            {
                file.CopyTo(ms);
                imagemBytes = ms.ToArray();
            }

            ParamBuilder param = new ParamBuilder();
            var          json  = param.ComImagem(Convert.ToBase64String(imagemBytes))
                                 .ComFeatureType(Enum.FeatureType.WEB_DETECTION)
                                 .Construir();

            RespostaAPIGoogle resposta = await this.Post <RespostaAPIGoogle>("images:annotate", json);

            List <string> listaRetorno = new List <string>();

            if (resposta != null && resposta.Responses.Count > 0)
            {
                resposta.Responses.FirstOrDefault().
                WebDetection.BestGuessLabels.ForEach(x => listaRetorno.Add(x.Label));
            }

            return(listaRetorno);
        }