Jump to content

Browser and SMB files


Bacco
 Share

Recommended Posts

Hey, quick question:

How can I enter a SMB URI in the browser so that a remote file (e.g. 814_45.pdf) will be opened via SMB/CIFS?

Very important: After the user opened the file and manipulated it he must be able to save it directly under the server it was coming from (so not the local "My documents" but rather "server.com/dir/814_45.pdf")

Those links will be available on a web page. Not every user will be contected upfront with the original server via a mapped network drive! --> So the URI has to work with the server-address

I have done some trials but the URLs simply don't work. What am I doing wrong here?

Checked html-file onn local PC (server.com)

<html><head></head><body>adsf

WORKS: <a href="file://server.com/dir/814_45.pdf">bla</a><br>

nope <a href="file:///server.com/dir/814_45.pdf">bla</a><br>

WORKS: <a href="file:////server.com/dir/814_45.pdf">bla</a><br>

nope <a href="smb://server.com/dir/814_45.pdf">bla</a><br>

nope <a href="smb:///server.com/dir/814_45.pdf">bla</a><br>

nope <a href="smb:////server.com/dir/814_45.pdf">bla</a><br>

WORKS: <a href="\\server.com\dir\814_45.pdf">bla</a><br>

WORKS: <a href="\\\server.com\dir\814_45.pdf">bla</a><br>

WORKS: <a href="\\\\server.com\dir\814_45.pdf">bla</a><br>

</body></html>

--> With PDF all stored under local PC (Checked with IE)

None(!!!) working when having the file on my own PC:

<html><head></head><body>adsf

<a href="file://server.com/dir/814_45.pdf">bla</a><br>

<a href="file:///server.com/dir/814_45.pdf">bla</a><br>

<a href="file:////server.com/dir/814_45.pdf">bla</a><br>

<a href="smb://server.com/dir/814_45.pdf">bla</a><br>

<a href="smb:///server.com/dir/814_45.pdf">bla</a><br>

<a href="smb:////server.com/dir/814_45.pdf">bla</a><br>

<a href="\\server.com\dir\814_45.pdf">bla</a><br>

<a href="\\\server.com\dir\814_45.pdf">bla</a><br>

<a href="\\\\server.com\dir\814_45.pdf">bla</a><br>

</body></html>

Connected as network drives (from my PC):

file:///Y:/dir/%20&%20Analytics%20benefits.pdf

WORKS... but Acrobat (PDF= does only offer Save-As on the local PC (not the remote source where the PDF came from)

Works as it should (file on my PC):

file:///Y:/dir/presentation_slides2.ppt

- MS Office File (?)

- Save as stores the file on its remote location

Buuut - needs to be connected to network drives! (not feasable)

Any ideas how to fix this?

Thanks!

Link to comment
Share on other sites

Hi there, and welcome.gif

Is this of any help ?


/* ------------------------------------------------------ **
* smb_url.c
* ------------------------------------------------------ **
*/

#include <stdio.h>
#include <string.h>

#include "smb_url.h"

smb_url *smb_urlParse( char *src, smb_url *url )
/* ---------------------------------------------------- **
* Parse an SMB URL string into an smb_url structure.
*
* This is a very, very simplistic URL parser...just
* enough for demonstration purposes.
* It does not handle the full syntax of SMB URLs.
* It only handles absolute URLs, and does not do
* enough error checking. You can certainly do better,
* and superior examples can be found on on the web.
*
* The function returns NULL on error.
* ---------------------------------------------------- **
*/
{
int pos;
uchar *p;

/* Clear the smb_url structure first. */
(void)memset( url, 0, sizeof( smb_url ) );

/* Check for a correct prefix. */
pos = 0;
if( 0 == strncasecmp( "smb://", src, 6 ) )
pos = 6;
else
if( 0 == strncasecmp( "cifs://", src, 7 ) )
pos = 7;
else
return( NULL );

/* Check for an empty URL ("smb://"). */
if( '\0' == src[pos] )
return( url );

/* Copy the original string so that we can carve it up. */
src = strdup( &src[pos] );

/* Separate the server, share, path & context
* components.
*/
url->server = src;

/* Look for context. */
p = strrchr( src, '?' );
if( NULL != p )
{
*p = '\0';
url->context = ++p;
}

/* Share part next. */
p = strchr( src, '/' );
if( NULL != p )
{
*p = '\0';
url->share = ++p;
/* path part. */
p = strchr( p, '/' );
if( NULL != p )
{
*p = '\0';
url->path = ++p;
}
}

/* Look for the ntdomain & username subfields
* in the server string (the Authority field).
*/
p = strchr( url->server, '@' );
if( NULL != p )
{
*p = '\0';
url->user = url->server;
url->server = ++p;
/* Split the user field into ntdomain;user */
p = strchr( url->user, ';' );
if( NULL != p )
{
*p = '\0';
url->ntdomain = url->user;
url->user = ++p;
}
}

/* Look for a port number in the server string. */
p = strchr( url->server, ':' );
if( NULL != p )
{
*p = '\0';
url->port = ++p;
}

return( url );
} /* smb_urlParse */


void smb_urlContent( smb_url *url )
/* ---------------------------------------------------- **
* Dump the contents of an smb_url structure,
* representing a parsed SMB URL string.
* ---------------------------------------------------- **
*/
{
if( url->ntdomain )
(void)printf( "ntdomain: %s\n", url->ntdomain );
if( url->user )
(void)printf( " user: %s\n", url->user );
if( url->server )
(void)printf( " server: %s\n", url->server );
if( url->port )
(void)printf( " port: %s\n", url->port );
if( url->share )
(void)printf( " share: %s\n", url->share );
if( url->path )
(void)printf( " path: %s\n", url->path );
if( url->context )
(void)printf( " context: %s\n", url->context );
} /* smb_urlContent */

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy