Search code examples
htmlwordpressftpsynologynas

Host files locally with predictable/controllable URL on Synology NAS


I am trying to find the best way to host a bunch of pdfs(and other files potentially) on my synology DS1821+ that can be accessed by a URL so employees can access them by scanning a QR code. The files should be available to any device connected to our WiFi.

I was able to achieve this quite easily using WordPress and simply uploading the files to the "Media Library" And converting the URL to QR code using my web browser.

Here is an example of one of the URLs provided:

http://10-0-1-128.synologynas.direct.quickconnect.to/wordpress/wp-content/uploads/2022/10/F09042-fix.pdf

this also works:

http://10.0.1.128/wordpress/wp-content/uploads/2022/10/F09042-fix.pdf

However, since we would be printing potentially thousands of QR codes to be used around the factory for years to come I need the URL to be something I can control manually, without stuff like "2022" in it so that if someday we switch to different software/hardware we can replicate the same structure so as not to need to reprint and redistribute thousands of QR codes.

I see the application "File Station" on my NAS and this is close to what I want but not quite. There I can right click a file -> share ->QR code and it returns something like this:

http://gofile.me/73nWA/C8AYNuBpv

Pretty cool, but again the URL is not something I can control, and also it uses some advanced voodoo to make the link work anywhere on the internet and these need to only work on our local network.

Any thoughts on the simplest way to achieve wat I'm looking for?

-Thanks

Edit -

I see now that I can add a folder to the "web" directory using File Station, and then add files to that folder and access them in my web browser by going to:

/folder/filename.pdf - (although if I right click it and say open in new tab it access it through a long and convoluted url???)

which is basically what I wanted however, I would like to be able to also go to:

/folder and see a selectable list of all the files as well

I know I can create I link by adding something like

<a href="file.pdf" etc etc etc

to the .html file, but I'm working with about potentially thousands of files.

Is there a way to just generate one for every file in the folder.

as I'm sure you can tell I'm a noob at this.


Solution

  • Figured it out.

    As long as you have some web server SW up and running you should be able to acces files placed in the /web folder of the "file station." for example if there is a pdf in the web folder named document.pdf you can access it by going to /document.pdf in your browser on local network.

    If there is a folder name named pdf with files in it in the /web folder you can add index.php to that folder with the following code in it to see a list of links to the files in it in your web browser.

    <?php
        $dir = "/volume1/web/pdf";
        // Open a directory, and read its contents
        if (is_dir($dir)){
            if ($dh = opendir($dir)){
                while (($file = readdir($dh)) !== false){
                    echo "   <a href=./$file>$file</a><br>";
                } 
                 closedir($dh);
            }
        }
    ?>