Page 1 of 1

Downloading an Excel File from VLWeb

Posted: Thu Jan 18, 2018 8:21 am
by jyoung
I am creating an Excel file with Integrator and am trying to download it through a Server Module.

Code: Select all

srvroutine name(Download) response(#response)
field_map for(*INPUT) field(#RequestId) parameter_name(RequestId)

#COM_OWNER.CreateExcelFile( #wk_FilePath )

#SYS_APPLN.TraceMessageData( ('Excel File Created At &1').Substitute( #wk_FilePath ) )

#response.ContentFile := #wk_FilePath
#response.AttachmentFileName := 'PTORequest.xlsx'
endroutine
And invoking it as such

Code: Select all

evtroutine handling(#DownloadButton.Click)
define_com class(#PTORequestModule.Download) name(#download) target(New)

#download.Execute requestid(#RequestId)
endroutine
The file is created an the trace output shows it is at "C:\Program Files (x86)\LANSA\X_WIN95\X_LANSA\x_sys\object\MyExcelDocument.xlsx"

The problem is that the download is constantly returning a 404 error.
file_not_found.png
file_not_found.png (16.56 KiB) Viewed 4455 times
I was following along with this post viewtopic.php?f=3&t=194&p=675 but I can't get the error to stop.

I am thinking it may be a permission issue, perhaps IIS (in this case) does not have permissions to the folder?
How can I get the server module to download the File?

EDIT
Tried setting the ContentType to 'application/vnd.ms-excel' thinking that perhaps IIS could not serve XLSX files, that did not work.
Tried writing to the *TEMP_DIR which for me is C:\Windows\Temp and that did not work either, although the File is clearly there.

Re: Downloading an Excel File from VLWeb

Posted: Fri Jan 19, 2018 4:17 am
by jyoung
Come to find out there where two problems:
  1. The JSM was experiencing a FATAL error.
  2. Apparently you cannot serve files from *TEMP_DIR


The command causing the FATAL error was this:

Code: Select all

#JSMXCMD := ('SAVE FILE(&1)').Substitute( #filePath )
It should have been this

Code: Select all

#JSMXCMD := ('SAVE FILE("&1")').Substitute( #filePath )
Ugh, notice the quotes around the parameter.

Secondly no matter what I did I could not get a file to be downloaded from *TEMP_DIR, again I think this is due to the permissions of the Temp Folder.

When I moved the file to *PART_DIR it worked finally.

Re: Downloading an Excel File from VLWeb

Posted: Fri Jan 19, 2018 9:23 am
by soa
A file can only be downloaded via browser from a folder which is exposed to the public by your web server definition (IIS). You should configure IIS to expose the \temp folder and reference this in the url. You should avoid exposing details about the 'real' locations of data via the web for security reasons.