# Download image from an URL

**URL:** <https://forum.inductiveautomation.com/t/download-image-from-an-url/79385>\
**Category:** General Discussion\
**Tags:** perspective, scripting\
**Created:** [September 20, 2023, 12:23pm UTC](https://forum.inductiveautomation.com/t/download-image-from-an-url/79385 "2023-09-20T12:23:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![THauptman](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@THauptman](https://forum.inductiveautomation.com/u/THauptman)\
**Post date:** [September 20, 2023, 12:23pm UTC](https://forum.inductiveautomation.com/t/download-image-from-an-url/79385/1 "2023-09-20T12:23:17Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 20, 2023, 1:41pm UTC](https://forum.inductiveautomation.com/t/download-image-from-an-url/79385/2 "2023-09-20T13:41:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![THauptman](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@THauptman](https://forum.inductiveautomation.com/u/THauptman)\
**Post date:** [September 21, 2023, 5:39am UTC](https://forum.inductiveautomation.com/t/download-image-from-an-url/79385/3 "2023-09-21T05:39:09Z")

</div>

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

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 6:01am UTC](https://forum.inductiveautomation.com/t/download-image-from-an-url/79385/4 "2023-09-21T06:01:51Z")

</div>

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 ...

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code]
