I am new to ASP.net and wondering how easy it is to download a photo from an external domain (Amazon S3) using their expiring link and save the photo in browser memory for another script to pick which uses the OpenBinary method? This allows me to resize and watermark before printing on the screen.
This is what I want:
In loadImage.aspx, I get a photo ID from my database, create a signed URL for Amazon S3, call the photo somehow and save it in memory. When in memory, my ASP.Jpeg script will call the OpenBinary method, resize and watermark the photo and use the SendBinary method to display the photo.
I think a memory stream or a binary response record may be the thing I'm looking for, but don't know how to use it on an external source. This is what I still managed, but was embarrassed and thought I was getting help, because I'm not sure if this will work if I can load a photo of external domains into memory, if I miss something important ...
My picture element:
<img src="loadImage.aspx?p=234dfsdfw5234234">
On loadImage.aspx:
string AWS_filePath = "http://amazon............" using (FileStream fileStream = File.OpenRead(AWS_filePath)) { MemoryStream memStream = new MemoryStream(); memStream.SetLength(fileStream.Length); fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length); }
Any help would be awesome.
source share