예제 #1
0
        public JsonResult UploadMaterial(MediaUploadTypes type)
        {
            var context = this.OS.WorkContext.HttpContext.Request.Files ?? null;

            if (context == null || context.Count.Equals(0))
            {
                return(Json(new { result = "fail" }, JsonRequestBehavior.AllowGet));
            }

            using (var stream = new BinaryReader(context[0].InputStream))
            {
                var buffers = stream.ReadBytes(context[0].ContentLength);
                switch (type)
                {
                case MediaUploadTypes.AuthMaterial:
                {
                    ////TODO 需要返回 url
                    var result = this.WeChat.UploadMaterial(context[0].FileName, buffers);
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }

                default:
                {
                    var result = this.WeChat.UploadMaterialToCDN(buffers);
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                }
            }
        }
예제 #2
0
        public static string GenerateWxUploaMediaUrl(string token, MediaUploadTypes type)
        {

            switch (type)
            {
                case MediaUploadTypes.AuthMaterial:
                    return string.Format("https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type=image", token);
                default: // Image
                    return string.Format("https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token={0}", token);

            }
        }
예제 #3
0
 public ImageUploadUIElement(
     string name,
     string text,
     MediaUploadTypes type,
     string value    = null,
     bool required   = false,
     string imageUrl = null,
     string message  = null)
     : base(name, text, value, required, message)
 {
     this.MediaUploadTypes = type;
     this.Value            = value;
     this.ImageUrl         = imageUrl;
 }