So I wrote my scraper and passed a C# class (card) into IronPython, which it then happily loaded with what I think is binary image data into a byte[]
like so:
imageurl = "http://blabla.com/Image.ashx?id=" + card.Id + "&type=card"
imageresult = urllib2.urlopen(imageurl).read()
if imageresult == '':
print 'Could not find image for ' + card.Title
card.AddImage(imageresult) # AddImage(byte[])
I then persist this and pull it from the database with NHibernate and tried to pull it back with this on my MVC front end:
var ms = new MemoryStream(card.Image);
var image = Image.FromStream(ms); // ***Parameter is not valid.***
Had I just written this out to a file instead of a C# object with Python, I'm fairly sure this would work. My question is, is there a good way to tell what the conversions will look like between IronPython and CLR data types? My binary sucks, I'm just not real sure what to do about it, in this case.