Skip to main content
Version: 8.1

system.perspective.download

This function is used in Python Scripting.

Description​

Downloads data from the Gateway to a device running a Session.

When calling from the Gateway scope, the call must include a sessionId.

New in 8.1.14

This function interacts with mobile apps directly to ensure that download requests can be saved to the local device. Requires version 1.0.2 of the Ignition Perspective App.

Syntax - Gateway Scope​

tip

This function accepts keyword arguments.

system.perspective.download(filename, data, [contentType], sessionId, [pageId])

Parameters​

TypeParameterDescription
StringfilenameSuggested name for the downloaded file.
StringdataThe data to be downloaded. May be a string, a byte[], or an InputStream. Strings will be written in UTF-8 encoding.
StringcontentTypeValue for the "Content-Type" header, for example: "text/plain; charset=utf-8". [optional]
StringsessionIdIdentifier of the Session to target. If omitted, the current Session will be used automatically. When targeting a different session, then the pageId parameter must be included in the call.
StringpageIdIdentifier of the page to target. If omitted, the current page will be used automatically. [optional]

Returns​

Nothing

Scope​

Gateway, Perspective Session

note

This function will only work in the Gateway scope if both sessionId and pageId are supplied to the call.

Syntax - Session Scope​

tip

This function accepts keyword arguments.

system.perspective.download(filename, data, [contentType], [sessionId], [pageId])

Parameters​

TypeParameterDescription
StringfilenameSuggested name for the downloaded file.
StringdataThe data to be downloaded. May be a string, a byte[], or an InputStream. Strings will be written in UTF-8 encoding.
StringcontentTypeValue for the "Content-Type" header, for example: "text/plain; charset=utf-8". [optional]
StringsessionIdIdentifier of the Session to target. If omitted, the current Session will be used automatically. When targeting a different session, then the pageId parameter must be included in the call. [optional]
StringpageIdIdentifier of the page to target. If omitted, the current page will be used automatically. [optional]

Returns​

Nothing

Scope​

Perspective Session

Code Examples​

Code Snippet

# Downloads the file "myFile.pdf" (located on the Gateway) to the user running the current Session.

filename = 'myFile.pdf'
data = system.file.readFileAsBytes('C:\\'+filename)
system.perspective.download(filename, data)