My goal is to execute a SOAP API call and get a prediction from the Microsoft Azure Custom vision prediction API.
The documentation for the API call:
Set Prediction-Key Header to : someRandomGeneratedcode
Set Content-Type Header to : application/octet-stream
Set Body to : <image file>
My question is how can I convert an image to the content-type application/octet-stream?
Things I tried are:
Convert the image to a Base64String what resolves in the error badRequestImageFormat.
lFile.Open(ptxtImagepath, TextEncoding::UTF16);
lFile.CREATEINSTREAM(lisInStream);
lnMemStream := lnMemStream.MemoryStream();
COPYSTREAM(lnMemStream, lisInStream);
lnArray := lnMemStream.GetBuffer();
pbtxtImage.ADDTEXT(lnConvert.ToBase64String(lnArray));
lFile.close();
use the dotnet Binaryreader like the following example. Which resolves in the following error: Unable to read beyond
the end of the stream.
lFile.Open(ptxtImagepath, TextEncoding::UTF8);
lFile.CREATEINSTREAM(lisInStream);
lnMemStream := lnMemStream.MemoryStream();
COPYSTREAM(lnMemStream, lisInStream);
lbrBinaryReader := lbrBinaryReader.BinaryReader(lnMemStream, lEncoding.UTF8());
IF NOT ISNULL(lbrBinaryReader) THEN BEGIN //read value from BLOB field
IF lbrBinaryReader.BaseStream().Length() > 0 THEN
ltxtBigText := lbrBinaryReader.ReadString();
lbrBinaryReader.Close();
END;
//**********
pbtxtImage.ADDTEXT(ltxtBigText);
lFile.close();