Disguise URL of downloadable file

Discussion in 'ASP General' started by JJ, Aug 23, 2004.

  1. JJ

    JJ Guest

    Hi,
    I am writing a cart in ASP selling downloadable files.
    The files are stored on remote locations i.e.
    http://www.thisfilestore.com/file1.zip

    And have different extensions, i.e. they are not all zip files.
    I would like to write a script which cann be called which will allow the
    download of the file, without giving away the url.

    Any Ideas/examples welcome!
    Thanks in Advance
    JJ
    JJ, Aug 23, 2004
    #1
    1. Advertising

  2. JJ

    Steven Burn Guest

    #1. Place them OUTSIDE of the web root
    #2. Place them OUTSIDE of the web root
    #3. Place them OUTSIDE of the web root

    Once outside of the web root, they cannot be downloaded directly and thus,
    you could simply just call the file whenever you <whatever it is your
    wanting to do>

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "JJ" <nospam> wrote in message
    news:4129ea1d$0$29945$...
    > Hi,
    > I am writing a cart in ASP selling downloadable files.
    > The files are stored on remote locations i.e.
    > http://www.thisfilestore.com/file1.zip
    >
    > And have different extensions, i.e. they are not all zip files.
    > I would like to write a script which cann be called which will allow the
    > download of the file, without giving away the url.
    >
    > Any Ideas/examples welcome!
    > Thanks in Advance
    > JJ
    >
    >
    Steven Burn, Aug 23, 2004
    #2
    1. Advertising

  3. "JJ" <nospam> wrote in message
    news:4129ea1d$0$29945$...
    > Hi,
    > I am writing a cart in ASP selling downloadable files.
    > The files are stored on remote locations i.e.
    > http://www.thisfilestore.com/file1.zip
    >
    > And have different extensions, i.e. they are not all zip files.
    > I would like to write a script which cann be called which will allow the
    > download of the file, without giving away the url.
    >
    > Any Ideas/examples welcome!


    Store the files outside of the web root path (so they don't actually have a
    URL) and use ADODB.Stream and Response.BinaryWrite to send them to the
    client.

    http://www.aspfaq.com/show.asp?id=2161
    http://support.microsoft.com/?kbid=276488

    --
    Tom Kaminski IIS MVP
    http://www.microsoft.com/windowsserver2003/community/centers/iis/
    http://mvp.support.microsoft.com/
    http://www.iisfaq.com/
    http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
    http://www.tryiis.com
    Tom Kaminski [MVP], Aug 23, 2004
    #3
  4. You need to create a page that processes the download. The path to the file
    can be anywhere but you just give the querystring param just the file name
    (or ID number) then do something like this (I think)

    ------------------------
    <%
    filename = server.mappath("") ' Fill in the filename e.g. test.pdf,

    Response.Buffer = True

    dim objFSO, objTS
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objTS = objFSO.OpenTextFile(fileName)

    sFileType= Right(fileName,4)
    NameFile=Right(FileName,Len(FileName)-InstrRev(FileName,"\"))
    Select Case strFileType
    Case ".asf"
    ContentType = "video/x-ms-asf"
    Case ".avi"
    ContentType = "video/avi"
    Case ".doc"
    ContentType = "application/msword"
    Case ".zip"
    ContentType = "application/zip"
    Case ".xls"
    ContentType = "application/vnd.ms-excel"
    Case ".gif"
    ContentType = "image/gif"
    Case ".jpg", "jpeg"
    ContentType = "image/jpeg"
    Case ".wav"
    ContentType = "audio/wav"
    Case ".mp3"
    ContentType = "audio/mpeg3"
    Case ".mpg", "mpeg"
    ContentType = "video/mpeg"
    Case ".rtf"
    ContentType = "application/rtf"
    Case ".htm", "html"
    ContentType = "text/html"
    Case ".asp"
    ContentType = "text/asp"
    Case Else
    'Handle All Other Files
    ContentType = "application/octet-stream"
    End Select
    response.contenttype=ContentType
    response.AddHeader "content-disposition", "inline; filename=" & NameFile

    Do While Not objTS.AtEndOfStream
    strChunk = objTS.Read(32)
    strTmp = ""
    For i = 1 to Len(strChunk)
    strTmp = strTmp & ChrB(Asc(Mid(strChunk, i, 1)))
    Next
    Response.BinaryWrite strTmp
    Response.Flush
    Loop
    objTS.Close
    Set objTS = Nothing
    Set objFSO = Nothing
    %>
    ------------------

    Found this by searching the web, by looking at it it _might_ be similar to
    what you are after.
    In the code you can state the dir where all your files live...but don't
    state it in the QS.

    Good luck
    Stu


    "JJ" <nospam> wrote in message
    news:4129ea1d$0$29945$...
    > Hi,
    > I am writing a cart in ASP selling downloadable files.
    > The files are stored on remote locations i.e.
    > http://www.thisfilestore.com/file1.zip
    >
    > And have different extensions, i.e. they are not all zip files.
    > I would like to write a script which cann be called which will allow the
    > download of the file, without giving away the url.
    >
    > Any Ideas/examples welcome!
    > Thanks in Advance
    > JJ
    >
    >
    Stuart Palmer, Aug 23, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maziar Aflatoun

    Creating a downloadable file on the fly

    Maziar Aflatoun, Dec 22, 2003, in forum: ASP .Net
    Replies:
    9
    Views:
    454
    JDModev
    May 10, 2004
  2. TJS
    Replies:
    2
    Views:
    456
    Kevin Spencer
    Feb 22, 2005
  3. Jason
    Replies:
    9
    Views:
    481
    Neredbojias
    Sep 16, 2005
  4. Tomás Ó hÉilidhe

    OK to disguise a macro function as a function?

    Tomás Ó hÉilidhe, Feb 12, 2008, in forum: C Programming
    Replies:
    4
    Views:
    348
    Army1987
    Feb 13, 2008
  5. Peter Bunyan
    Replies:
    9
    Views:
    139
    Lloyd Linklater
    Nov 23, 2007
Loading...

Share This Page