using Newtonsoft.Json;
|
using RestSharp;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using YouZanSDKStandard.Api.Response;
|
|
namespace YouZanSDKStandard.Api
|
{
|
public class YouZanUploadeImg
|
{
|
/// <summary>
|
/// 图片上传有赞
|
/// </summary>
|
/// <param name="accessToken"></param>
|
/// <param name="filePath"></param>
|
/// <returns></returns>
|
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<UploadImageResponse>(response.Content);
|
return topRsp;
|
}
|
return null;
|
}
|
}
|
}
|