I'm using the following code to download an image:
Dim strImageURL as string = "http://images.bookworld.com.au/images/bau/97817433/9781743315187/0/0/plain/the-storyteller.jpg"
Dim data As Byte()
Using client As New WebClient()
data = client.DownloadData(strImageURL)
'client.DownloadFile(strImageURL, "MyFile.jpg")
End Using
File.WriteAllBytes("\\mappedPath\Images\MyFile2.jpg", data)
The code works fine for most cases, but we've come across an image that once saved, is corrupted..
This is the troubling URL: http://images.bookworld.com.au/images/bau/97817433/9781743315187/0/0/plain/the-storyteller.jpg
I tried using the code above and then the "client.DownloadFile" line thinking that they may have different results, but I keep getting a corrupted file.
I am able to hit the URL and Chrome displays the image fine.. I can save the file to my local machine fine too.. but using the above code, I just get corrupted .jpg files for this particular URL..
I suspect the image is on some kind of image serving service and possibly not sending something quite correctly.. but I'm not sure..
I even tried the same code in C# to see what it would do, but I got the same result.. :-(
If anyone can help sort this out, I'd be very grateful..
Thanks.