Today, i got requirement from one of the my client, he wants to show external images in his website, like YouTube preview image, Google video thumbnail, Flicker images. When user add the URL to his server, these images are cached in his server.

Then i had small research and it is possible in PHP and other languages but there no result for ASP. I tried using ADODB stream to get images and finally i got success.
The below example, I’m downloading file from Google website.
if strGoogleThumbPath <> “” then
Set objHTTP = Server.CreateObject(“MSXML2.ServerXMLHTTP”)
objHTTP.Open “GET”, “http://www.southdreamz.com/friends/gamersERA.jpg”
objHTTP.Send
strSaveFileName = “C:path-to-output-file.jpg”
call SaveBinaryData(strSaveFileName, objHTTP.responseBody)
Set objHTTP = nothing
end if
‘ — save Binary content into file
function SaveBinaryData(FileName, ByteArray)
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Dim BinaryStream
Set BinaryStream = CreateObject(“ADODB.Stream”)
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.Write ByteArray
BinaryStream.SaveToFile FileName, adSaveCreateOverWrite
end function
%>


















