# Ignition Perspective file download

**URL:** <https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 22, 2024, 10:17pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246 "2024-04-22T22:17:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jykl5](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jykl5](https://forum.inductiveautomation.com/u/jykl5)\
**Post date:** [April 22, 2024, 10:17pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246/1 "2024-04-22T22:17:50Z")

</div>

When trying to download a ZIP file via system.file.readFileAsBytes, I get the error:

_Size cannot be greater than Integer max value: 3488226777_

I don't see another Perspective function other than readFileAsBytes, is it possible to use Java functions instead inside the script to allow for downloading large files?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 22, 2024, 10:22pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246/2 "2024-04-22T22:22:57Z")

</div>

Can you show some code?

The function you mentioned doesn't do the action you're describing.

---

<div class="post-metadata">

**Author:** ![jykl5](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@jykl5](https://forum.inductiveautomation.com/u/jykl5)\
**Post date:** [April 22, 2024, 10:46pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246/3 "2024-04-22T22:46:04Z")

</div>

Yes, this is the script. It pulls the filename from a filetree then downloads it. Small file sizes work, but files greater than 2-3Gb don't work:

> filename = result[0]['fileLocation'].split('\')[-1]  
> data = system.file.readFileAsBytes(result[0]['fileLocation'])  
> system.perspective.download(filename, data)

The error in full is:

Error running action 'component.onActionPerformed' on Report/file share@C$0:0/root/download: Traceback (most recent call last): File "function:runAction", line 2, in runAction File "", line 11, in download at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:467) at org.apache.commons.io.FileUtils.readFileToByteArray(FileUtils.java:1675) at com.inductiveautomation.ignition.common.script.builtin.FileUtilities.readFileAsBytes(FileUtilities.java:144) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Size cannot be greater than Integer max value: 3488226777

---

<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:** [April 22, 2024, 10:49pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246/4 "2024-04-22T22:49:17Z")

</div>

Tip: format the code as code rather than as a quote. See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831). It will catch you out on Python and general code indentation.

---

<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:** [April 22, 2024, 10:53pm UTC](https://forum.inductiveautomation.com/t/ignition-perspective-file-download/89246/5 "2024-04-22T22:53:50Z")

</div>

`readFileAsBytes` returns a primitive Java `byte[]` under the hood. Java arrays are limited to 32 bit signed integer keys; thus the largest a Java byte array can be is 2,147,483,647 bytes.

But...what on earth are you serving up via Perspective that's (often) greater than 2gB, and how has your gateway not exploded from loading these massive byte arrays into memory?

There's no way to 'stream' massive result sets to consumers entirely via Perspective, which is absolutely what you'd want to do here for performance. I would **strongly** advocate setting up a 'reverse proxy' software on your gateway in front of Ignition that's capable of (efficiently) hosting these large files.
