using Newtonsoft.Json;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Text;
using YouZanSDKStandard.Api.Response;
namespace YouZanSDKStandard.Api
{
public class YouZanUploadeImg
{
///
/// 图片上传有赞
///
///
///
///
public static UploadImageResponse UploadImage(string accessToken, string filePath)
{
var client = new RestClient($"https://open.youzanyun.com/api/youzan.materials.storage.platform.img.upload/3.0.0?access_token={accessToken}");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddFile("image", filePath);
IRestResponse response = client.Execute(request);
if (response.Content != null && response.Content != "")
{
UploadImageResponse topRsp = JsonConvert.DeserializeObject(response.Content);
return topRsp;
}
return null;
}
}
}