I have an problem with sending binary data from ionic app. The app capture an photo from camera in base64 format and she must send this in binary data format to API server. I have to sent the image at the azure cognitive service for image recognize.
this is my capture function :
public takeFoto(){
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
correctOrientation:true,
saveToPhotoAlbum: true
}
this.camera.getPicture(options).then((imageData) => {
this.myPhoto = 'data:image/jpeg;base64,' + imageData;
this.imgData = imageData;
}, (err) => {
// Handle error
});
}
and this is my post function :
classifica(){
this.crudService.postAzureApi( /*binary data*/ '','https://northeurope.api.cognitive.microsoft.com/vision/v2.0/tag').then((result)=>{
console.log(result);
this.resultPost = result;
},(err)=> {
console.log(err);
this.resultPost = err;
});
}
the header are : content-type : application/octet-stream and apikey