Пример #1
0
        /// <summary>
        ///  上传图片并获取地址
        ///      没有mediaId【图文】【微店】
        /// </summary>
        /// <param name="imgReq"></param>
        /// <returns></returns>
        public WxArticleUploadImgResp UploadFreeImage(WxMediaFileReq imgReq)
        {
            var req = new OsHttpRequest();

            req.HttpMothed = HttpMothed.POST;
            req.AddressUrl = string.Concat(m_ApiUrl, "/cgi-bin/media/uploadimg");
            req.FileParameterList.Add(new FileParameter("media", imgReq.file_stream, imgReq.file_name, imgReq.content_type));

            return(RestCommonOffcial <WxArticleUploadImgResp>(req));
        }
Пример #2
0
        public void UploadImgeMediaTest()
        {
            var imageFile = new FileStream("E:\\1.jpg", FileMode.Open, FileAccess.Read);

            var req = new WxMediaFileReq();

            req.content_type = "image/jpeg";

            req.file_name   = "1.jpg";
            req.file_stream = imageFile;

            var res = m_Api.UploadFreeImage(req);

            Assert.IsTrue(res.IsSuccess);
            //http://mmbiz.qpic.cn/mmbiz_jpg/N3louEAebXzhBzgsstFNBicyF1j1ZFIGgV55uQHPXLGDwIIDkvxrcnhEVGsEphEicICPLQ7Fh5kubPJg59u0rtFA/0
        }