上传图片返回结果
Inheritance: Senparc.Weixin.Entities.WxJsonResult
コード例 #1
0
ファイル: PictureApi.cs プロジェクト: yueliuhun/WeiXinMPSDK
        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
ファイル: PictureApi.cs プロジェクト: cnand0ng/WeiXinMPSDK
        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
ファイル: PictureApi.cs プロジェクト: xin-young/WeiXinMPSDK
        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);
        }