• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Open a PDF from button click

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Open a PDF from button click

    What I am I doing wrong?
    Is there a better way to access PDFs stored on a network server?

    We have PDFs saved on our Windows Server... I've created a connection to the server using MKDIR '/QNTC/totalbizsvr2'.

    I can access the PDF files using WRKLNK on that directory.

    Code:
    Directory  . . . . :   /QNTC/totalbizsvr2/Compliance/Templates
    Object link Type
    . DDIR
    .. DDIR
    Truck Test.pdf DSTMF
    However, I get file not found when I try to access this using a URL widget from a row button.
    The URL is /QNTC/totalbizsvr2{TMPL_PATH}
    Where TMPL_PATH = '/compliance/templates/Truck Test.pdf'

    We are running at password level 3 and all users have the Windows and IBM i user/passwords synchronized.

  • #2
    Can you access the link directly from your browser? If not, you will need to open up access to the folder via your Apache configuration, similar to how Valence resources is setup in the config file

    Example:
    http://yourIBMi:PORT/QNTC/totalbizsv...emplates/Truck Test.pdf

    Example Valence resources
    http://yourIBMi:PORT/resources/images/valence_logo.png

    Comment


    • #3
      So I added this to my apache config and restarted it...

      125 # Compliance Files on TOTALBIZSVR2 alias
      126 Alias /compliance /QNTC/totalbizsvr2/compliance
      127 <Directory /compliance>
      128 Order Allow,Deny
      129 allow from all
      130 </Directory>
      131

      now I'm getting a forbidden message

      Forbidden

      Forbidden - by rule.

      You do not have permission to access /compliance/Templates/Test.pdf on this server.

      Do you know what user profile is being used?

      Comment


      • #4
        Are you attempting to access it directly from the browser or within a NAB app. If directly in a browser I would think it would use the QTMHHTP1 profile.

        If through NAB, then it would be the user profile linked to your Valence login.

        Comment


        • #5
          Doing this from within NAB. I have no issues when my URL widget is pointing to the same file in a different IFS directory. Example: /gwilburn/compliance is an IFS share.

          I can do WRKLNK('/QNTC/totalbizsvr2/Compliance') and view the PDF file on the green screen. This is not shared as an IFS share.

          But I still get the Forbidden by rule message.

          Can I debug this somehow?

          I would really like to have my PDFs stored on the Windows server instead of an IFS Share.

          Comment


          • #6
            If I try to access the file via ACS
            actions are not allowed.png

            Comment


            • #7
              I think your apache config is wrong.

              Code:
              <Directory /compliance>
              Should be
              Code:
              <Directory /QNTC/totalbizsvr2/compliance>

              Comment


              • #8
                I changed that, but I still get the same error... IBM pointed me to this document.
                https://www.ibm.com/support/pages/se...pache-and-qntc

                I'm not sure if this is required or not... I would hate to have to maintain a user just to access files.

                Comment


                • #9
                  It seems this is the user id that would be used to authenticate on your Windows server. If you do not want to set up maybe you can spin up a web server on the Windows machine that serves the PDFs. Then you would no longer need to use the QNTC route.

                  Comment


                  • #10
                    I was able to get this working using NFS...

                    We created a NFS share (called /NFSShare) on our Windows server. This was helpful:
                    https://computingforgeeks.com/instal...indows-server/

                    Then used these instructions to create a share (/nfsshare) and mount the file system from the IBM i:
                    https://github.com/richardschoen/how...t_nfs_share.md

                    (I used the Windows file server name instead of the IP)

                    Finally, add the Apache Alias & Directive:
                    Code:
                    # Files on Windows Server NFS Share alias
                    Alias /nfs /nfsshare
                    <Directory /nfsshare>
                    Order Allow,Deny
                    allow from all
                    </Directory>


                    Comment


                    • #11
                      Glad to hear. Thanks for posting back the solution.

                      Comment


                      • #12
                        So I discovered a snag...

                        Let's say someone opens the PDF from my app. All is good. But then someone changes the contents of the PDF. The next time that same person opens the PDF again, it is not downloading/opening the new document. It appears to be using a cached version of the PDF doc.

                        Is there a way I can force the browser to open the document each time?

                        Comment


                        • #13
                          Here is an older post on adding a cache buster

                          Comment


                          • #14
                            Originally posted by Johnny Major View Post
                            Here is an older post on adding a cache buster
                            Thanks... I tried both methods. Adding a timestamp to the data source works, but only if you refresh the data source between changes.
                            Setting the app variable then manipulating it with JavaScript is more "steps" but seems to work regardless.

                            Is there a preferred method?

                            Comment


                            • #15
                              We are planning to add a new setting to the URL widget that will automatically apply a cache buster on load. This means that you won't have to do anything except check the corresponding setting.

                              Comment

                              Working...
                              X