Binary Image Stream

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
LantraxAsked:
Who is Participating?
 
sybeConnect With a Mentor Commented:
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
 
LantraxAuthor Commented:
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
 
LantraxAuthor Commented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LantraxAuthor Commented:
also i am using imnpersonation. Do i set anything here for that?
0
 
sybeCommented:
* 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
 
LantraxAuthor Commented:
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
 
LantraxAuthor Commented:
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
 
sybeCommented:
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
 
LantraxAuthor Commented:
Do you know why i would get this error.


ADODB.Stream error '800a0bba'

File could not be opened.
0
All Courses

From novice to tech pro — start learning today.