Download image from an URL

Hello everyone.

We would like to download an image - snapshot from an ip camera using URL and store file on the gateway as .jpg

URL path to this camera image is like this:
http://admin:password@192.xxx.xxx.xxx:port/images/snapshot.jpg

This task(script) would be executed on the gateway event. What syntax should we use to achive this?

Thank you for your help

Start with system.net.httpClient performing a GET request.

Thank you for pointing us in the right direction. We made it work.

Here is the code if anyone should need to do the same

url = 'http://192.xxx.xxx.xxx:port/images/snapshot.jpg'
response = system.net.httpClient().get(url, timeout=20000)
image = response.getBody()
system.file.writeFile("C:/Folder/file.jpg", image)
1 Like

You've formatted your code using the quotation button instead of the code formatting button. We can read it in this case but for future posts see ...