0

openFile <-> openURL

While waiting for a possible "openFile" command, the openURL command can provide the same services on MacOS:

To open a file with the default application of MacOS you can use openURL because Ninox accepts, in addition to the start of path syntax "http: //", the syntax "file: ///" which does not launch the MacOS default browser but the default MacOS application defined by the extension of the file names to open. We can use the openURL command in a "On click" trigger of a button or a formula field to:

- Open any type of file contained in an image-field or in the "File attachments" tab of a record.

To do this, use the Ninox internal file path whose root is of type:

file: ///Users/ericplet/Library/Containers/de.ninoxdb.ninox-mac.Ninox/Data/Documents/data/PletList/files/O/2/Respect - Paroles.pdf

Where "ericplet" is the user's directory, "PletList" is the name of the database in Ninox, "O" is the table code and "2" is the record ID.

- Open any type of file in a folder on the hard drive

To do this, use the path defined by the MacOS Finder, such as:

file: /// Library / WebServer / Documents / PlayLists / Jazz / Autumn Leaves.mp4

In this case, the path is also that of a local Web server that can be used with a browser with the syntax:

http: //MacBookProEric.local/PlayLists/Jazz/Autumn Leaves.mp4

- Use openURL as command: Display in Finder

- Use openURL to launch an application

- Since we can place the openURL command in any script of any trigger, personally, this lifted all the limits I had encountered.

- We can even launch the opening of a file when opening the database ...

13 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    I tried openURL("file:///...") in a button "On click" and it still opens my PDF file in Preview instead of my default PDF app. When I double-click on the same file in Finder it opens in the default PDF app.

    • Retraité
    • Eric_Plet
    • 4 yrs ago
    • Reported - view

    I just tested with the Ninox manual in PDF:
    To obtain the opening with the default application, it is necessary to generalize the default opening on all PDF files.
    Read Information window from Finder for PDF manual Ninox.
    Open with, example: Google Chrome
    Click on the button: Modify all.

    • Sean
    • 4 yrs ago
    • Reported - view

    Screen Shot 2020-03-01 at 12.36.01 PM

     

    The app is set as default for all PDF files and that is why said double-clicking on the same file in Finder opens it in the default PDF app. The PDF file opens in the default app if I click on an icon on my desktop and also if I click on a link in an OpenOffice Calc spreadsheet. Is there another setting you are referring to?

    • Retraité
    • Eric_Plet
    • 4 yrs ago
    • Reported - view

    When I wanted to take the test, at first I also had, in my case, as Preview default application.
    So I opened the Read info window for the Ninox manual PDF file and selected the Google Chrome app instead of Preview.
    But then I got the same result as you: it was always with the Preview application that the PDF file was opened ...
    So I went back to the Read PDF file information window and this time I clicked on the Change All button.
    After that, the file was opened with Google Chrome and no longer with Preview.
    I specify that my Mac is under Catalina…
    Maybe try modifying the default application and clicking the modify all button to see if it reacts otherwise.

    • Phil
    • 4 yrs ago
    • Reported - view

    This sounds awesome. But I can't get this working. Can you please elaborate on how to open a file, a folder or an application on my Mac using a button? I'm not sure about the spaces and " " characters and so on. If I could make this work it would reduce the file size of my database considerably.

    • Retraité
    • Eric_Plet
    • 4 yrs ago
    • Reported - view

    First of all test the following path in Safari:

    file:///Library/WebServer/Documents

    This should open a Finder window and tell you the contents of the Documents folder.

    Warning: if you have to test several times, a new window is required in Safari for each new test.

    If this test does not work it may be for a reason of right of access ...

    • Roland_Breuer
    • 4 yrs ago
    • Reported - view

    Thank you for this awsome solution. It works perfectly for the directory "file:///Library/WebServer/Documents" but as soon I change it to "file:///Users/xyz/..." nothing happens... Is there perhaps a permission problem with "file:///Users/"?

    Any hints how to solve this problem?

    Thank you!

    • Phil
    • 4 yrs ago
    • Reported - view

    same here. it works fine for folders and files in the Libaray folder and also to open apps like so

    openURL("file:///System/Applications/Contacts.app")

    but nothing happens with files and folders inside the Users folder. any idea?

    • Retraité
    • Eric_Plet
    • 4 yrs ago
    • Reported - view

    It is precisely the limit that I myself encountered during my first tests that I wanted to clarify to you ;-(
    Subsequently I was able to realize that this path root corresponding to the default WebServer site of MacOS X became, in any case in my opinion, an advantage and the ideal location.
    I created a first general access folder at the beginning of the root to give the following path:
    file:///Library/WebServer/Documents/Médiathèque
    If the WebServer service is active on the Mac used, it is no longer simply the Mac but all of the equipment connected to the local network which can access the files using a simple browser. For example, simple tablets and smartphones will therefore be able to use the Ninox database and the browser of their system to access documents.
    In this case, the root of the path must be as follows:
    http://MacBookProEric.local/Médiathèque
    MacBookProEric.local being the name of the computer recognized on the local network by the Bonjour service. The station's IP address could also do the trick.
    If you use the syntax http: // it is the default browser which is used to access files only but on the whole local network.
    If you use the syntax file: /// it is with the Mac and the default application which is normally used to open and not the browser and you can also access the Finder in this case if you specify the path for a folder or application.
    For all my tests I used in a Ninox form first a simple URL field.
    Then you can place the openURL command in any script as an On Click trigger for a button or a formula field.
    The best I could do for the Mac was to create a text file containing an XSPF file and then start opening the same file which starts AudioVideo playback in the VLC application.
    And soon I will focus on using the iPad as a client on the local network which will be able to access the multimedia files of the Mac from Ninox by exploiting Safari and only files in Video mp4 format which goes very well on the iPad with Safari ;-)

    • havrup
    • 4 yrs ago
    • Reported - view

    Eric,

    I have plenty of PDF files I want to open with openURL. It all works perfectly when I put my directory in the path 

    file:///Library/WebServer/Documents/MyPDFFileDircetory

    but I like to use a directory elsewhere on my MAC. I spent some time to search for a solution but can't understand how I (as an user) can change the permission for NINOX so that app can access a folder "of my choice" through the command "open URL". Do you know if there is a way or I'm stuck using file:///Library/WebServer/Documents/....

    /Niclas 

    • Retraité
    • Eric_Plet
    • 4 yrs ago
    • Reported - view

    sorry, i don't have a solution ;-(

    • gggg
    • 3 yrs ago
    • Reported - view

    anyone knows how could be used in windows OS?

    • buy
    • 2 yrs ago
    • Reported - view

    I have solved this on a project by using an image data field to upload the CSV file.

    I have add a sharefile() as a on change trigger. So when a user upload the file it creates a share. Then I use this share to open the CSV with http("GET", share name)     

    for i in split(concat(http("GET", ShareURL).result), "

    " do . ...

    Then I parse each lines of the CSV file with my business programming rules.

Content aside

  • 9 mths agoLast active
  • 13Replies
  • 4787Views
  • 2 Following