Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to samba shares in html

Tags:

html

samba

smb

First off if you're unaware, samba or smb == Windows file sharing, \\computer\share etc.

I have a bunch of different files on a bunch of different computers. It's mostly media and there is quite a bit of it. I'm looking into various ways of consolidating this into something more manageable.

Currently there are a few options I'm looking at, the most insane of which is some kind of samba share indexer that would generate a list of things shared on the various samba servers I tell it about and upload them to a website which could then be searched and browsed.

It's a cheap solution, OK?

Ignoring the fact that the idea is obviously a couple of methods short of a class, do you chaps know of any way to link to samba file shares in html in a cross-browser way? In windows one does \\computer\share, in linux one does smb://computer/share, neither of which work afaik from browsers that aren't also used as file managers (e.g. any browser that isn't Internet Explorer).

Some Clarifications

  • The computers used to access this website are a mixture of WIndows (XP) and Linux (Ubuntu) with a mixture of browsers (Opera and Firefox).
  • In linux entering smb://computer/share only seems to work in Nautilus (and presumably Konqueror / Dolphin for you KDE3.5/4 people). It doesn't work in Firefox or Opera (Firefox does nothing, Opera complains the URL is invalid).
  • I don't have a Windows box handy atm so I'm unsure if \\computer\share works in anything apart from IE (e.g. Firefox / Opera).
  • If you have a better idea for consolidating a bunch of random samba shares (it certainly can't get much worse than mine ;-)) it's worth knowing that there is no guarantee that any of the servers I would be wanting to index / consolidate would be up at any particular moment. Moreover, I wouldn't want the knowledge of what they have shared lost or hidden just because they weren't available. I would want to know that they share 'foo' but they are currently down.
like image 213
SCdF Avatar asked Sep 01 '08 11:09

SCdF


People also ask

How do I connect to a Samba share?

Simply open the file manager and in the address bar (Figure F) and type \\SERVER\SHARE, where SERVER is the IP address of the machine hosting the Samba share and SHARE is the name of the actual share.


3 Answers

Hmm, protocol handlers look interesting.

As Mark said, in Windows protocol handlers can be dealt with at the OS level

Protocol handlers can also be done at the browser level (which is preferred, as it is cross platform and doesn't involve installing anything).

Summary of how it works in Firefox
Summary of how it works in Opera

like image 145
SCdF Avatar answered Oct 03 '22 06:10

SCdF


I'd probably just setup Apache on the SAMBA servers and let it serve the files via HTTP. That'd give you a nice autoindex default page too, and you could just wget and concatenate each index for your master list.

A couple of other thoughts:

  1. file://server/share/file is the defacto Windows way of doing it
  2. You can register protocol handlers in Windows, so you could register smb and redirect it to file://. I'd suspect GNOME/KDE/etc. would offer the same.
like image 30
Mark Brackett Avatar answered Oct 03 '22 04:10

Mark Brackett


To make the links work cross platform you could look at the User Agent either in a CGI script or in JavaScript and update your URLs appropriately.

Alternatively, if you want to consolidate SMB shares you could try using Microsoft DFS (which also works with Samba).

You set up a DFS root and tell it about all the other SMB/Samba shares you have in your environment. Clients then connect to the root and see all the shares as if they were hosted on that single root machine; the root silently redirects clients to the correct system when they open a share.

Think of it as like symbolic links or a virtual file system for SMB.

It would solve your browsing problem. I'm not sure if it would solve your searching one.

like image 38
Dave Webb Avatar answered Oct 03 '22 04:10

Dave Webb