1

I have MediaWiki installed on a synology server. I would like to create a link on the wiki that would allow opening of files on the same server.

Here are the steps I did to achieve this:

  • Added $wgUrlProtocols[] = "file://"; in LocalSettings.php
  • A test file on the server: file://myServerName/path/to/file/test.txt. Putting this URL in my chrome browser directly opens the file.
  • Create a page in MediaWiki with a link to this file using [[file://myServerName/path/to/file/test.txt]]

When I click on the generated wiki page, nothing happens. However when I hover on top of the link, it shows the correct URL.

Can someone please point out what additional steps I need to do to get this working?

locke14
  • 1,335
  • 3
  • 15
  • 36

1 Answers1

1

The file:// protocol points to the file on your computer. I'm not fully sure, but I think you cannot use it to retrieve file from a different machine (read my comment below about samba shares).

From quick research it looks like Chrome browser blocks requests with file:// protocol, But browsers like IE should allow you to open those files. It is done because of security reasons so the malicious site cannot open local files without your permission. You might bypass that by installing a special plugin in Chrome (look for Enable file links)

Instead of using file protocol, make those files available via Synology WebStation, and then create links that point to the file via webstation (not via path on the server). With that approach, links attached on your MediaWiki pages will work as those will be regular links.

If you don't use the WebStation, you might also try with ftp:// links (use the FTP service), or link to samba shares - that's where the file:// protocol might work, but again - I'm not sure and I cannot test it as I do not use windows.

I think that the safest/easiest/fastest way is to expose those files via WebStation.

Source: https://en.wikipedia.org/wiki/File_URI_scheme

The file URI scheme is a URI scheme defined in RFC 8089, typically used to retrieve files from within one's own computer.

PolishDeveloper
  • 930
  • 5
  • 17
  • But I can still open the files directly in my browser using the `file` protocol. That means that synology is ok with that, right? – locke14 May 14 '20 at 08:14
  • Hmm, are you using windows? Most probably you access that file via samba share. It may be possible that browser prevents opening the file if it's a link on the site but still allows you to do it if you enter it directly in the url bar (same as you can open file from explorer). Maybe try doing the same thing in Internet Explorer/Edge. Now I'm really curious why it works if you put it directly into the url bar. Also @locke14 - please check this resourece: https://community.spiceworks.com/topic/533009-opening-file-links-from-within-chrome - Looks like chrome blocks opening file resources – PolishDeveloper May 14 '20 at 09:45
  • Thanks. Yes, I'm using windows. It's the same behavior in edge as well.. – locke14 May 14 '20 at 14:02