请问这段C#博客园图片上传API代码为何不能运行?
请问我按照 chrome 的 request 提取数据用C# RestSharp 做博客园本地上传图片API功能,结果是失败的,请问我以下代码错在哪边呢?
或是大神们有更好的做法?
var filePath = @"C:\Users\xxxx\Downloads\Snipaste_2020-08-21_15-56-36.jpg";var fileName = filePath.Split('\\').Last();
var client = new RestClient($"https://upload.cnblogs.com/imageuploader/CorsUpload");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("origin", "https://q.cnblogs.com");
request.AddHeader("referer", "https://q.cnblogs.com/q/new");
request.AddHeader("cookie", "涉及资安");
request.AddFile("imageFile", File.ReadAllBytes(filePath), Path.GetFileName(filePath));
request.AddParameter("host", "www.cnblogs.com");
request.AddParameter("uploadType", "Paste");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
回答
用fiddler =>raw;然后用tcp写进去
以上是 请问这段C#博客园图片上传API代码为何不能运行? 的全部内容, 来源链接: utcz.com/a/40031.html