开发者

Storing Images as binary in DB from external URL

I am currently in the midst of migrating a site from ZenCart to NopCommerce (PHP to .Net). I am writing a routine to transfer the products from one to the other. I have finished this now with only one aspect remaining, the images. In Zencart, the location of the image is stored in the database, but in NopCommerce its s开发者_Python百科tored as a binary in the database.

Can anyone help with a way to write images to an SQL Server DB as binary from an external url.


You can easily use the WebClient class or the HttpWebRequest/HttpWebResponse to fetch the images at a particular url.

You would call the DownloadData method on the WebClient class or call the GetResponseStream method on the HttpWebResponse returned from a call to HttpWebRequest.GetResponse to get the bytes.

Then, you can insert the blobs into your DB as normal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜