This example shows how to retrieve and display a thumbnail that's been saved as metadata.



Instead of dynamically returning a page of HTML to the browser, what we want to do is dynamically return image data to the browser. We'll create a page for this and call it view.asp.

Rather than hardwire the image in the code we'll include the name of the image in the URL. In this way you can write code which references different images. For example you might use the following HTML to display the preview of the boat.

<img src='view.asp?name=boat'>



We start by retrieving the name that was supplied to us. From the name we can derive the URL for the image and also the physical path to the file.

<% @Language="VBScript" %>
theName = Request.QueryString("
theURL = "images/" & theName & ".jpg"

thePath = Server.MapPath(theURL)



Next we assign the path to a File object and retrieve the preview metadata that we created earlier.

Set theFile = Server.CreateObject("MetaFiler2.File")
Set theData = theFile.Open("preview")



Finally we write an appropriate content type, so that the browser will know that it's getting image data and not HTML, and then we write the preview to the client.

Response.ContentType = "image/jpeg"
Response.BinaryWrite theData.Data



The result is an image generated dynamically and displayed on the client browser.