Image base64 in Angularjs to c# varbinary(max)

南笙酒味 提交于 2019-12-25 07:50:35

问题


I have this class TBEquipamento in my webservice :

public partial class TBEquipamento
    {
        public int idEquipamento { get; set; }
        public int idTipoEquipamento { get; set; }
        public Nullable<int> idLocalidade { get; set; }
        public string NumSerie { get; set; }
        public string TAG { get; set; }
        public string Potencia_KVA { get; set; }
        public Nullable<float> TensaoPrimaria_V { get; set; }
        public Nullable<float> TensaoSecundaria_V { get; set; }
        public Nullable<int> idFabricante { get; set; }
        public Nullable<int> AnoFabricacao { get; set; }
        public Nullable<float> Volume_L { get; set; }
        public Nullable<int> idEqOperando { get; set; }
        public Nullable<int> idSistemaRefrigeracao { get; set; }
        public Nullable<int> idComutador { get; set; }
        public Nullable<int> idTipoOleo { get; set; }
        public Nullable<int> idSistemaPreservacao { get; set; }
        public byte[] FotoEquipamento { get; set; }
}
}

And this function to POST in it:

 // POST: função add equipamento    
        [HttpPost]
        [Route("api/insertequipamento")]
        [ResponseType(typeof(TBEquipamento))]
        public async Task<IHttpActionResult> insertequipamento([FromBody] TBEquipamento addequipamento)
        {    

                objapi.TBEquipamento.Add(addequipamento);
                await objapi.SaveChangesAsync();

                return Ok("confirmationSuccess");

        }

The problem is when a pass a data to FotoEquipamento, I tried to pass a base64 and blob data to it from my Angularjs, but it doesn't work.

My image in angularjs is in my $scope.FotoEquipamento, and if I print it in console is: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4RDoRXhpZgAATU0AKg [...]'

Do you guys have any ideia of how can a POST that image? Thank you all for the attetion.

来源:https://stackoverflow.com/questions/41400016/image-base64-in-angularjs-to-c-sharp-varbinarymax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!