Solved

Binary Image Stream

Posted on 2004-10-27
400 Views
Last Modified: 2010-05-18
I have images that are stored on my network.  The servers that the images are stored on are not accessible via http. So I have a user account created and am using impersonation to get to the directory on this server which holds the images.

I have to Binary stream these images to get them onto the web browser and I can't use a 3rd party component. I have to do it all in ASP.

Any ideas as to how I can do this?


-Inter
0
Question by:Lantrax
    9 Comments
     

    Author Comment

    by:Lantrax
    I can also use FSO but i am not sure how to get that to work with impersonation. the directory is somthing like this:

    \\TheServer\Folder1\CompanyName\

    Is there any way that i can do this. Either Binary Streaming or FSO or anything..

    -INter
    0
     
    LVL 28

    Accepted Solution

    by:
    Sub WriteFileToBrowser(ByVal sFilePath, ByVal sContentType, ByVal sDisplayName)
        Dim oStream
        Set oStream = Server.CreateObject("ADODB.Stream")
        oStream.Type = 1
        oStream.Open
        oStream.LoadFromFile sFilePath
        Response.ContentType = sContentType
        Response.AddHeader "Content-Disposition", "filename=" & sDisplayName
        Response.AddHeader "Content-Length", oStream.Size
        Response.BinaryWrite oStream.Read
        oStream.Close
        Set oStream = Nothing
    End Sub
    0
     

    Author Comment

    by:Lantrax
    I don;t mean to be ignorant but i am.... LOL..

    what is sContentType and sDisplayname?

    I am confused on those. Also how will i get this to work in classic asp. can i just convert it into a function?

    -INter
    0
     

    Author Comment

    by:Lantrax
    also i am using imnpersonation. Do i set anything here for that?
    0
     
    LVL 28

    Expert Comment

    by:sybe
    * sContenttype should be something like "image/gif" or "text/plain" or whatever the MIME-type of the document is
    * sDisplayname should be something like "myimage.gif" or "documentname.doc". When you stream the file to the browser using an ASP, and the user wants to save it, then that will be the default name. Otherwise the defaultname would be the name of the ASP file which is doing the job of streaming the file to the browser.
    0
     

    Author Comment

    by:Lantrax
    I am streaming an image. Is there a way that i can get teh dimentions and then resize the image on the fly without resizing it on the server but just on the display for the browser?

    0
     

    Author Comment

    by:Lantrax
    Darn... I can't get the File straem to work because i have to implement impersonation. Do you know how that is done using this object?
    0
     
    LVL 28

    Expert Comment

    by:sybe
    that's a completely other question.

    1. getting the dimensions means you have to look inside the binary code of the image. I have seen code like that somewhere, try to google it.
    2. resizing on the client is easy: <image src="yourstreamingpage.asp" width="50%" height="50%">
    0
     

    Author Comment

    by:Lantrax
    Do you know why i would get this error.


    ADODB.Stream error '800a0bba'

    File could not be opened.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Lean Six Sigma Project Manager Certification

    There are many schools of thought around successful project management, but few as highly regarded as the Six Sigma and Lean methods. With 37 hours of learning, this training will explain concrete processes for increasing efficiency and limiting wasted time and effort.

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now