Page 1 of 1

Http call returns image

PostPosted: Thu May 04, 2023 5:19 pm
by cdmmaui
Hello Everyone,

Can someone provide sample code that makes http request and that request returns a JPG image that I need to save on local HD?

Thank you,

Re: Http call returns image

PostPosted: Thu May 04, 2023 5:27 pm
by karinha

Re: Http call returns image

PostPosted: Thu May 04, 2023 5:29 pm
by Antonio Linares

Re: Http call returns image

PostPosted: Sat May 06, 2023 3:50 pm
by nageswaragunupudi
If the URL refers to a jpg image like this
"https://cdn.images.express.co.uk/img/dynamic/109/590x/Apple-links-587431.jpg"
We can save the jpg with just one function like this in one single line of code:
Code: Select all  Expand view
cURL  := "https://cdn.images.express.co.uk/img/dynamic/109/590x/Apple-links-587431.jpg"
MEMOWRIT( "myfile.jpg", WebPageContents( cURL ) ) // This one line of code does the job

// Check if saved correctly
XIMAGE( "myfile.jpg" )
 


Note: The function WebpageContents( cUrl ) uses oHttp for reading the contents of any web-page