上传图片返回结果
상속: Senparc.Weixin.Entities.WxJsonResult
예제 #1
0
        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);
        }
예제 #2
0
        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;
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }