internal Folder Redirect?

i dont know how to describe this

Page 1 of 1

4 Replies - 3675 Views - Last Post: 15 June 2010 - 11:21 AM Rate Topic: -----

#1 MrReclusive  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 17-November 09

internal Folder Redirect?

Posted 11 June 2010 - 10:36 AM

ok we have a database that was created years ago for an access program.
our company has expanded allot and we are trying to offer some easy to use features for our clients.
they log into website, they get info on any current projects and/or work orders, they get a inventory list of all computers they have, etc..

There is some pdf and doc files located on a server in our office (total of 12 servers in office) that are related to specific customers, and the path to these files are stored in the database.

we need them to be able to download these files from the website.
Our webserver is "server04"
These documents are stored on "server05" and "server07"

example path to file
\\server04\Datastore\Customers\C\XXX\XXX\file.pdf

is there a way to have the server "get" this file and "give" it to the client.

There is over 100,000 files and database records that I don't want to move around.

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: internal Folder Redirect?

#2 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: internal Folder Redirect?

Posted 13 June 2010 - 02:02 PM

I'm sorry but the web browser can only access files or web pages available on the web server (in the website or web application).
If I were you I'd create an aspx page that doesn't server HTML to the browser...instead this web page would fetch the file that you need (using the IO namespace) and write the file to the Response stream. You will also need to change the header to indicate that you are not sending HTML to the browser.

-Frinny
Was This Post Helpful? 1
  • +
  • -

#3 MrReclusive  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 17-November 09

Re: internal Folder Redirect?

Posted 15 June 2010 - 10:24 AM

sorry for late response, been busy and web design is not my main job in this company.

If I Mounted the path //server07 and //server05 to virtual drives like Y:\ and Z:\
could i then in code change //server07 to y:\ and //server05 to z:\
and then go from there?

this is the first time I have every tried to link to a file that was outside the root of a site.
Was This Post Helpful? 0
  • +
  • -

#4 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: internal Folder Redirect?

Posted 15 June 2010 - 10:52 AM

This is how it works:

There is an image tag in the HTML code that points to the image resource. The web browser sees this and sends a request to the server for the image and the web sever returns it.

If the image is located somewhere else on the network (or even outside of the website on the same computer) the image cannot be downloaded by the browser.

So, what I was recommending is that you create an aspx page that retrieves the image (from across the network in your case) and returns it to the browser.

So, instead of having an image tag's src attribute point directly to the image in the website, you have it point to the aspx page instead. Typically you pass the ID of the image you need to request using the Query String so that this aspx page knows what to retrieve for you.

In the aspx page you have to change the content header type etc.

I remember seeing a tutorial on the topic recently (I think it's on this site)....or not.... ah, it's a code snippet for: Creating Thumbnails....

All you have to do is remove the code that shrinks the image :)
And modify it so that it retrieves the image from where ever you need to retrieve it from...


If you need help understanding the snippet just ask :)

You may run into problems accessing images across the network (due to the reduced permissions that the ASPNET user account is given) so I recommend, for testing purposes, to try this code on an image that is located within the same folder as the website first...then, when you get this to work, try across the network (you may need to use impersonation to do this properly)

-Frinny

This post has been edited by Frinavale: 15 June 2010 - 10:57 AM

Was This Post Helpful? 1
  • +
  • -

#5 Frinavale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 203
  • View blog
  • Posts: 776
  • Joined: 03-June 10

Re: internal Folder Redirect?

Posted 15 June 2010 - 11:21 AM

Actually I just looked at that code and it's not really what I would do.....
So I'm posting the code snippet that I think would be more appropriate for you to modify for your needs:
Imports System.Drawing.Imaging
Imports System.Reflection
''' <summary>'
''' This ASPX page does not display HTML content.'
''' It is used to retrieve images.'
''' </summary>'
''' <remarks></remarks>'
Partial Public Class ThumbnailImage
    Inherits System.Web.UI.Page

    Private imageName As String 'Will contain the image name '
    Private imageUrl As String 'Will contain the URL path to the image '
    Private _imagePath As String = System.Configuration.ConfigurationManager.AppSettings("TempImagesUrlPath") 'Contains the relative url path to the folder where the images are located '



    ''' <summary>'
    ''' Handles the Page Load event.'
    ''' </summary>'
    ''' <param name="sender">The Object that raised the event.</param>'
    ''' <param name="e">The EventArgs for the event</param>'
    ''' <remarks></remarks>'
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Changing the page content type to display images'
        Response.ContentType = "image/jpg"

        'Retrieving the name of the image to display'
        imageName = Request.QueryString("imgName")

         If String.IsNullOrEmpty(imageName) Then
           'If there is no image specified, displaying the default cardholder image'
            RetrieveDefaultImage()
        Else
            'Retrieving the image'
            imageUrl = String.Format("{0}{1}", _imagePath, imageName)
            RetrieveImageFromExistingFile()
        End If

    End Sub
    ''' <summary>'
    ''' Retrieves the requested image.'
    ''' </summary>'
    ''' <remarks></remarks>'
    Private Sub RetrieveImageFromExistingFile()
        If IO.File.Exists(Server.MapPath(imageUrl)) Then
            'Retrieving the full size image from the imageURL (the URL path to the image)'
            Dim fullSizeImg As System.Drawing.Image
            fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(imageUrl))

            'Saving the image to the Response.OutputStream'
            fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg)

            'Cleaning up resources'
            fullSizeImg.Dispose()
        End If
    End Sub

    ''' <summary>'
    ''' Displays a default image (which is embedded) if no id was provided'
    ''' </summary>'
    ''' <remarks></remarks>'
    Private Sub CreateDefaultThumbnail()
    
        Dim asm = Assembly.GetExecutingAssembly 'Getting a reference to the executing assembly'
        For Each resourceName As String In asm.GetManifestResourceNames 'looping through each resource name
            If resourceName.Contains("DefaultImage") Then 'If the resource name is "DefaultImage" ...'
                'Retrieving a stream to the embedded resource
                Dim readerfs As System.IO.Stream = asm.GetManifestResourceStream(resourceName)
                'Creating an Image based on the stream for the embedded resource'
                Dim fullSizeImg As System.Drawing.Image
                fullSizeImg = System.Drawing.Image.FromStream(readerfs)
                'Writing the image directly to the output stream'
                fullSizeImg.Save(Response.OutputStream, ImageFormat.Jpeg)
                'cleaning up the image'
                fullSizeImg.Dispose()
                'cleaning up the stream'
                readerfs.Close()
                Exit For
            End If
        Next

    End Sub
End Class

This post has been edited by Frinavale: 15 June 2010 - 11:23 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1