public static PictureResult UploadImg(string accessToken, string fileName) { var urlFormat = Config.ApiMpHost + "/merchant/common/upload_img?access_token={0}&filename={1}"; var url = string.IsNullOrEmpty(accessToken) ? urlFormat : string.Format(urlFormat, accessToken.AsUrlData(), fileName.AsUrlData()); var json = new PictureResult(); using (var fs = FileHelper.GetFileStream(fileName)) { var jsonText = RequestUtility.HttpPost(CommonDI.CommonSP, url, null, fs); json = Senparc.Weixin.HttpUtility.Post.GetResult <PictureResult>(jsonText); } return(json); }
public static PictureResult UploadImg(string accessToken, string fileName) { var urlFormat = "https://api.weixin.qq.com/merchant/common/upload_img?access_token={0}&filename={1}"; var url = string.IsNullOrEmpty(accessToken) ? urlFormat : string.Format(urlFormat, accessToken, fileName); var json=new PictureResult(); using (var fs = FileHelper.GetFileStream(fileName)) { var jsonText = RequestUtility.HttpPost(url, null, fs); json = Post.GetResult<PictureResult>(jsonText); } return json; }
public static PictureResult UploadImg(string accessToken, string fileName) { var urlFormat = "https://api.weixin.qq.com/merchant/common/upload_img?access_token={0}&filename={1}"; var url = string.IsNullOrEmpty(accessToken) ? urlFormat : string.Format(urlFormat, accessToken, fileName); var json = new PictureResult(); using (var fs = Senparc.Weixin.Helpers.FileHelper.GetFileStream(fileName)) { var jsonText = Senparc.Weixin.HttpUtility.RequestUtility.HttpPost(url, null, fs); json = Senparc.Weixin.HttpUtility.Post.GetResult <PictureResult>(jsonText); } return(json); }
public static async Task <PictureResult> UploadImgAsync(string accessToken, string fileName) { var urlFormat = "https://api.weixin.qq.com/merchant/common/upload_img?access_token={0}&filename={1}"; var url = string.IsNullOrEmpty(accessToken) ? urlFormat : string.Format(urlFormat, accessToken.AsUrlData(), fileName.AsUrlData()); var json = new PictureResult(); using (var fs = FileHelper.GetFileStream(fileName)) { var jsonText = await RequestUtility.HttpPostAsync(url, null, fs); json = Post.GetResult <PictureResult>(jsonText); } return(json); }