ASP – Cache external images

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.

ASP logo ASP   Cache external images

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
%>

Interested in writing Technology tips for SouthDreamZ.com?

Are you interested in writing Technology articles for SouthDreamZ.com or updating ASP – Cache external images article? You can! SouthDreamZ.com is currently looking for writers who are interested in writing Technology articles. Send your articles to [email protected], for more details visit Feature Yourself page.
On this article, we have tried to provide all the information on ASP – Cache external images. However, if you encounter any discrepancy in the information about ASP – Cache external images, do write to us. We welcome any kind of feedback that would improve the quality of the site, a site that strives to provide the best information on ASP – Cache external images.