Exemple #1
0
 private void RequestToken()
 {
     OAuthConsumer consumer = OAuthConsumer.KuaipanConsumer();
     KuaipanClient client = new KuaipanClient(consumer, true);
     if (!client.RequestToken())
     {
         return;
     }
     Session["oAuth"] = client;
     Response.Redirect(client.GetAuthorizeUrl());
 }
Exemple #2
0
        protected void BtUpdate_Click(object sender, EventArgs e)
        {
            var user = UserModel.Current(Session);

            OAuthConsumer consumer = OAuthConsumer.KuaipanConsumer();
            KuaipanClient client = new KuaipanClient(consumer, user.Token, true);
            var uri = client.Upload("/" + Web.PAGE_NAME + "/");

            MsMultiPartFormData form = new MsMultiPartFormData();
            form.AddStreamFile("file", "MetaName", Encoding.UTF8.GetBytes(HfData.Value));
            form.PrepareFormData();

            HttpUtil http = new HttpUtil();
            http.Encoding = Encoding.UTF8;
            http.Method = HttpMethod.POST;
            http.ContentType = "multipart/form-data; boundary=" + form.Boundary;
            http.Post(uri, form.GetFormData().ToArray());
        }
Exemple #3
0
 public KuaipanDownload(KuaipanClient client)
 {
     _Client = client;
 }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var type = context.Request["t"];

            OAuthToken token;

            //var c = context.Request["c"];
            //// 间接访问当前地址
            //if (string.IsNullOrWhiteSpace(c))
            //{
            // 加载用户授权
            var user = UserModel.Current(context.Session);
            var page = context.Session[Web.SESSION_META] as MMeta;
            if (page == null || page.Token == null)
            {
                if (type == "cat")
                {
                    context.Response.Write("[{ id:'0', pId:'0', name:'" + Web.PAGE_NAME + "', isParent:true, open:true}]");
                }
                else
                {
                    LoadDef(context);
                }
                context.Response.End();
                return;
            }
            token = page.Token;
            //}
            //// 直接访问当前地址
            //else if (CharUtil.IsValidateCode(c))
            //{
            //    token = Web.LoadToken(c, "kuaipan");
            //}
            //else
            //{
            //    return;
            //}

            var consumer = OAuthConsumer.KuaipanConsumer();
            var client = new KuaipanClient(consumer, token, true);

            // 加载页面目录
            if (type == "cat")
            {
                LoadCat(context.Response, client);
                context.Response.End();
                return;
            }

            // 获取要显示的页面
            var file = context.Request["f"];
            if (string.IsNullOrEmpty(file))
            {
                file = page.Default;
                if (string.IsNullOrWhiteSpace(file))
                {
                    file = LoadCfg(context, client);
                    if (string.IsNullOrWhiteSpace(file))
                    {
                        file = "/index.html";
                    }
                }
                page.Default = file;
            }
            if (file[0] != '/')
            {
                file = '/' + file;
            }

            var ext = (Path.GetExtension(file) ?? "").ToLower();
            if (ext[0] == '.')
            {
                ext = ext.Substring(1);
            }

            bool iok;
            //if (type == "src")
            //{
            switch (ext)
            {
                case "htm":
                case "html":
                    iok = LoadObj(context, client, file, "text/html");
                    break;
                case "txt":
                    iok = LoadTxt(context, client, file);
                    break;
                case "log":
                    iok = LoadTxt(context, client, file);
                    break;
                case "ini":
                    iok = LoadTxt(context, client, file);
                    break;
                case "as3":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushAS3.js\"></script>");
                    break;
                case "cpp":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushCpp.js\"></script>");
                    break;
                case "cs":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushCSharp.js\"></script>");
                    break;
                case "css":
                    if (type == "src")
                    {
                        iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushCss.js\"></script>");
                    }
                    else
                    {
                        iok = LoadObj(context, client, file, "text/css");
                    }
                    break;
                case "java":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushJava.js\"></script>");
                    break;
                case "jfx":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushJavaFX.js\"></script>");
                    break;
                case "js":
                    if (type == "src")
                    {
                        iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushJScript.js\"></script>");
                    }
                    else
                    {
                        iok = LoadObj(context, client, file, "text/javascript");
                    }
                    break;
                case "php":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushPhp.js\"></script>");
                    break;
                case "py":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushPython.js\"></script>");
                    break;
                case "rb":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushRuby.js\"></script>");
                    break;
                case "saas":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushSass.js\"></script>");
                    break;
                case "sql":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushSql.js\"></script>");
                    break;
                case "vb":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushVb.js\"></script>");
                    break;
                case "xml":
                    iok = LoadSrc(context, client, file, ext, "<script type=\"text/javascript\" src=\"/_js/sh/scripts/shBrushXml.js\"></script>");
                    break;
                default:
                    iok = LoadTxt(context, client, file);
                    break;
            }
            //}
            //else
            //{
            //    switch (ext)
            //    {
            //        case "htm":
            //        case "html":
            //            iok = LoadHtm(context, client, file);
            //            break;
            //        case "txt":
            //            iok = LoadTxt(context, client, file);
            //            break;
            //        case "log":
            //            iok = LoadTxt(context, client, file);
            //            break;
            //        case "ini":
            //            iok = LoadTxt(context, client, file);
            //            break;
            //        default:
            //            iok = true;
            //            break;
            //    }
            //}

            // 加载用户指定页面
            if (!iok)
            {
                LoadDef(context);
            }
            context.Response.End();
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            var type = context.Request["t"];

            OAuthToken token;

            //var c = context.Request["c"];
            //// 间接访问当前地址
            //if (string.IsNullOrWhiteSpace(c))
            //{
            // 加载用户授权
            var user = UserModel.Current(context.Session);
            var page = context.Session[Web.SESSION_META] as MMeta;
            if (page == null || page.Token == null)
            {
                if (type == "cat")
                {
                    context.Response.Write("[{ id:'0', pId:'0', name:'" + Web.PAGE_NAME + "', isParent:true}]");
                }
                else
                {
                    LoadDef(context);
                }
                context.Response.End();
                return;
            }
            token = page.Token;
            //}
            //// 直接访问当前地址
            //else if (CharUtil.IsValidateCode(c))
            //{
            //    token = Web.LoadToken(c, "kuaipan");
            //}
            //else
            //{
            //    return;
            //}

            var consumer = OAuthConsumer.KuaipanConsumer();
            var client = new KuaipanClient(consumer, token, true);

            if (type == "cat")
            {
                LoadCat(context.Response, client);
                context.Response.End();
                return;
            }

            var file = context.Request["f"];
            var ext = (Path.GetExtension(file) ?? "").ToLower();
            if (ext[0] == '.')
            {
                ext = ext.Substring(1);
            }

            if (ext == "png" || ext == "jpg" || ext == "jpeg" || ext == "gif")
            {
                LoadImg(context, client, file, ext);
                context.Response.End();
                return;
            }
        }
Exemple #6
0
 public KuaipanUpload(KuaipanClient client)
 {
     _Client = client;
 }