Hi
We have finally made the move from FGL 3.21 to 5.01 but have noted a behaviour we cannot explain when using the launchURL front call in conjunction with ui.Interface.filenameToURI to display stored documents.
We have a centralised function to do this as all documents are stored in a single document archive. The function is as below:
#+
#+ View a document by its ID
#+
#+ This function allows the user to download a document for viewing
#+
#+ The public record will be set holding the document ID and its actual name
#+
#+ Documents are stored by ID in an archive folder (the root of which is held in environment variable: FGL_DOCUMENTROOT)
#+ IDs are prepended with zeros to make them 12 characters in length, e.g. 215168 becomes 000000215168
#+ The folder structure for the above document is then:
#+
#+ $(FGL_DOCUMENTROOT)/000/000/215/000000215168
#+
#+ @return Nothing
#+
function sys_viewDocumentByID()
define sFileSource,
sFileDestination,
sDocumentUri string
if p_documentR.documentid is null then
return
end if
if p_documentR.documentname is null then
return
end if
# Get the full path to the document within the archive
let sFileSource = sys_getDocumentPath(p_documentR.documentid)
if sFileSource is null then
return
end if
# If using GBC, copy the document to the temporary area, renaming at the same time
# If all is well, get the URI and make the front call
if ui.Interface.getFrontEndName() = "GBC" then
try
let sFileDestination = os.Path.join(g_tmpServerDir.trim(), p_documentR.documentname.trim())
if os.Path.copy(sFileSource, sFileDestination) then
let sDocumentUri = ui.Interface.filenameToURI(sFileDestination)
call ui.Interface.frontCall("standard", "launchURL", [sDocumentUri], [])
end if
catch
call sys_showMessage(%"Error", sfmt(%"Unable to download file %1 to %2 (%3)", sFileSource, sFileDestination, status), "")
end try
return
end if
try
let sFileDestination = g_tmpClientDir.trim(), g_clientPathSeperator.trim(), p_documentR.documentname.trim()
call fgl_putfile(sFileSource, sFileDestination)
call sys_launchDocument(sFileDestination)
catch
call sys_showMessage(%"Error", sfmt(%"Unable to download file %1", sFileSource)||CRLF||sfmt("To: %1", sFileDestination), "")
return
end try
end function
For the time being we are able to run our codebase using FGL 3.21 or 5.01, hence the check for the front end type.
The above works well when the filename of the document has no spaces, e.g. image01.jpg, but fails when there are spaces.
For example, a filename of "Meeting Report.pdf" will fail. The result is the following URI, for which we get a bad request response in the browser:
https://app.alsico.co.uk/gas/ua/ft/6f73f925533f0d5470e57ba6ea7b762a/fgl-files/82966/Meeting%20Report.pdf?t=1746363820;s=461534;charset=UTF-8
However, if we replace the spaces with an underscore, i.e. "Meeting_Report.pdf", this results in a URI such as below, which works:
https://app.alsico.co.uk/gas/ua/ft/831139bc472031110b9fe19ea07f7add/fgl-files/82994/Meeting_Report.pdf?t=1746363908;s=461534;charset=UTF-8
Can anyone see any issues in the above code? Though the workaround is fine, it would be better for us not to have to manipulate the file name.
Thanks in advance
Gary
Hi Gary, works for me with FGL 5.01.02 and httdispatch 5.01.01 ... see attached.
Try at your side and if this doesn't work with your env contact the support.
I'd like to point you for displaying PDF's "inlined" to a simple webcomponent I came up with: it doesn't open a 2nd tab and you could integrate more seamless into your workflow.
Since 4.x it works painless in GBC and GDC (exception safari mobile: only the 1st page of the pdf is displayed as an image because it seems an iframe limitation of safari mobile).
Previously pdfjs was needed to render PDFs in a Genero Form, nowadays browsers are capable of displaying their own GUI for showing PDFs in an iframe.
See https://github.com/leopatras/wc_simplepdf
Regards, Leo
Gary,
You are light in details on what the front-end is, but is this a possibility https://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_mode_proxy_fcgi_spaces_in_filenames.html
Reuben
Hi
Thanks Leo, I'll look at your component as we may have a good use case for this.
Reuben, thanks, that was the issue. We are using Apache 2.4.52 on Ubuntu, but our proxy.conf file was incorrect and had the pre 2.4.11 settings.
Gary