using (var w = new WebClient()) { using (var ms = new MemoryStream()) { using (var image = Picture.Image) { using (MemoryStream m = new MemoryStream()) { image.Save(m, image.RawFormat); byte[] imageBytes = m.ToArray(); // Convert byte[] to Base64 String string base64String = Convert.ToBase64String(imageBytes); var values = new NameValueCollection { { "key", "2781d465a48c3e2" }, { "image", Convert.ToBase64String(imageBytes) } }; byte[] response = w.UploadValues("https://api.imgur.com/3/upload", values); var responseXml = XDocument.Load(new MemoryStream(response)); _imgurl = (string)responseXml.Root.Element("link"); } } } }
https://imgur.com/api/3/upload
https://imgur.com/api/3/image
http://imgur.com/api/3/upload.xml
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)