Cnblogs图片无法上传

   

2019年5月28日以前的两三个月时间,使用cnblogs原来的接口时,提示图片无法上传,空间不足,实在没办法了,自己实现了博客代理,发现上传图片时返回了503错误,只好先把图片传到其它服务器,再发布

http://www.cnblogs.com/qinqoushui/services/metaweblog.aspx

新接口

https://rpc.cnblogs.com/metaweblog/QinQouShui

 自己搭建的中转服务器

 

 

然后,cnblogs突然换了接口,图片上传正常了,一切都白费力气

   

复制代码
@@@code

public Stream newMediaObjectResponse(string blogid, string username, string password, FileData file)

{

//可行,偷梁换柱,先实现图片上传

if (string.IsNullOrEmpty(imageUrl))

{

mw.Credentials = new NetworkCredential(username, password);

var x = mw.newMediaObject(blogid, username, password, file);

return mw.newMediaObjectResponse(blogid, username, password, file).GetResponseStream();

}

else

{

string md5 = Q.Helper.HashHelper.MD5(file.bits);

string path = System.IO.Path.Combine(AppContext.BaseDirectory, "images");

if (!Directory.Exists(path))

Directory.CreateDirectory(path);

string fileName = md5 + "." + file.type.Split('/')[1];

if (!File.Exists(Path.Combine(path, fileName)))

File.WriteAllBytes(Path.Combine(path, fileName), file.bits);

   

XmlRpcResponse xmlRpcResp = new XmlRpcResponse(new UrlData() { url = $"{imageUrl}{fileName}" });

XmlRpcSerializer serializer = new XmlRpcSerializer();

Stream responseStream = new MemoryStream();

serializer.SerializeResponse(responseStream, xmlRpcResp);

responseStream.Seek(0, SeekOrigin.Begin);

return responseStream;

}

   

}

@@#

复制代码

   

纪念下

   

  

posted @   秦秋随  阅读(167)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗
点击右上角即可分享
微信分享提示