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;

}

 

}

@@#

 

纪念下

 

 

你可能感兴趣的:(Cnblogs图片无法上传)