Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Net;
- using System.Text;
- using Newtonsoft.Json.Linq;
- using System.Collections.Specialized;
- namespace MyShop.Tools
- {
- public class ImgBBExtension
- {
- private static readonly string _apiKey = "507d546dd56ee58e4da9ce88*********";
- private static readonly string _apiUrl = "https://api.imgbb.com/1/upload";
- public static string UploadImage(string imageBase64Data)
- {
- using (WebClient client = new WebClient())
- {
- NameValueCollection param = new NameValueCollection();
- param.Add("key", _apiKey);
- param.Add("image", imageBase64Data);
- var response = client.UploadValues(_apiUrl, "POST", param);
- var result = Encoding.UTF8.GetString(response);
- var json = JObject.Parse(result);
- var imageUrl = (string) json["data"]["url"];
- return imageUrl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement