[Qgis-user] file URIs (was: How to have photos appear in HTML tips *and* the attribute editor?)

Adam Nielsen a.nielsen at shikadi.net
Sun Apr 16 15:25:19 PDT 2023


> > P.S. I have seen many things saying you must specify the URL as
> > file:/// with three slashes to make it work under Windows, but under
> > Linux you must have only two slashes.  It would be nice if any solution
> > to this worked across all platforms.
> >  
> 
> I can't speak to solving your problem, but as to your PS:
> 
> 
> https://en.m.wikipedia.org/wiki/File_URI_scheme
> 
> will help you understand file URLs. Specifically the format is
> 
> file://host/path
> 
> and when host is omitted the slash delimiter is not.
> 
> Note especially the comment
> 
> ... two slashes, without a hostname) is never correct, but is often used

This is what I am doing.  If you look at that Wikipedia page and
compare the sections "Unix" and "Windows" you can see the issue.

Linux/Unix paths start with a leading slash already (no drive letters)
so the path "/project" with "file://" on the front ends up as
"file:///project" with three slashes, which is correct.

The problem is that same concatenation seems to break on Windows, as
"file://" and "c:/project" ends up with only two slashes which is not
correct.

The online guides tell you to use three slashes - "file:///" plus
"c:/project" which works on Windows, but when you move to Linux
"file:///" plus "/project" means you end up with four slashes which
does not work.

So there doesn't seem to be a way to convert the same path into a file
URI that works across both platforms.

Cheers,
Adam.


More information about the QGIS-User mailing list