(DataFlex) Download Image (JPG, GIF, etc.) to Base64
Demonstrates how to download an image, or any type of file, to get the data in base64 encoding format.
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Variant vBd
Handle hoBd
Boolean iSuccess
String sBase64_image_data
String sTemp1
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Get pvComObject of hoBd to vBd
Get ComDownloadBd Of hoHttp "https://www.chilkatsoft.com/images/starfish.jpg" vBd To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComGetEncoded Of hoBd "base64" To sBase64_image_data
Showln "image data in base64 format:"
Showln sBase64_image_data
End_Procedure
|