Esempio n. 1
0
        /// <summary>
        /// 获取token
        /// </summary>
        /// <param name="email"></param>
        /// <param name="handler">回调handler</param>
        public void token(string email, WP7HttpRequest.HttpResquestEventHandler handler)
        {
            WP7HttpRequest request = new WP7HttpRequest();

            request._httpCompleted += new WP7HttpRequest.HttpResquestEventHandler(handler);
            request.RequestUrl      = URL_OAUTH;
            request.AppendParameter("email", email);
            request.AppendParameter("client_id", _clientId);
            request.AppendParameter("client_secret", _clientSecret);
            request.RequestMethod = RequestType.POST;
            request.Request();
        }
Esempio n. 2
0
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="path">删除路径</param>
        public void Del(string path, string mount, WP7HttpRequest.HttpResquestEventHandler handler)
        {
            string signMethod = "del";
            string sign       = GenerateSign(signMethod, path);
            string encodePath = UrlEncoder.Encode(path);

            List <KeyValuePair <string, string> > paramList = new List <KeyValuePair <string, string> >();

            paramList.Add(new KeyValuePair <string, string>("path", encodePath));
            paramList.Add(new KeyValuePair <string, string>("token", _token));
            paramList.Add(new KeyValuePair <string, string>("mount", mount));
            paramList.Add(new KeyValuePair <string, string>("sign", Uri.EscapeUriString(sign)));

            WP7HttpRequest request = new WP7HttpRequest();

            request._httpCompleted += new WP7HttpRequest.HttpResquestEventHandler(handler);
            request.RequestMethod   = RequestType.POST;
            request.RequestUrl      = URL_API + GenerateUrl(signMethod, paramList);
            request.Request();
        }
Esempio n. 3
0
        /// <summary>
        /// 获取路径
        /// </summary>
        /// <param name="path">文件路径,文件夹后跟“/”</param>
        /// <param name="mount">mout=gokuai 删除该用户用的存储文件</param>
        /// <param name="type"></param>
        /// <param name="handler"></param>
        private void Head(string path, string mount, string type, WP7HttpRequest.HttpResquestEventHandler handler)
        {
            string signMethod = "head";
            string sign       = GenerateSign(signMethod, path);
            string encodePath = UrlEncoder.Encode(path);

            List <KeyValuePair <string, string> > paramList = new List <KeyValuePair <string, string> >();

            paramList.Add(new KeyValuePair <string, string>("path", encodePath.GetHashCode().ToString()));
            paramList.Add(new KeyValuePair <string, string>("token", _token));
            paramList.Add(new KeyValuePair <string, string>("mount", mount));
            paramList.Add(new KeyValuePair <string, string>("type", type));
            paramList.Add(new KeyValuePair <string, string>("sign", Uri.EscapeUriString(sign)));

            WP7HttpRequest request = new WP7HttpRequest();

            request._httpCompleted += new WP7HttpRequest.HttpResquestEventHandler(handler);
            request.RequestMethod   = RequestType.GET;
            request.RequestUrl      = URL_API + GenerateUrl(signMethod, paramList);
            request.Request();
        }
Esempio n. 4
0
        /// <summary>
        /// 应用复制
        /// </summary>
        /// <param name="path">文件路径,文件夹后跟“/”</param>
        /// <param name="mount">mout=gokuai 删除该用户用的存储文件</param>
        /// <param name="frompath">源路径 文件夹后跟“/”</param>
        /// <param name="overwrite">上传有同名文件是否覆盖,不传默认0, 0覆盖,1新建</param>
        /// <param name="handler"></param>
        public void Copy(string path, string frompath, string mount, int overwrite, WP7HttpRequest.HttpResquestEventHandler handler)
        {
            string signMethod = "copy";
            string sign       = GenerateSign(signMethod, path);
            string encodePath = UrlEncoder.Encode(path);

            List <KeyValuePair <string, string> > paramList = new List <KeyValuePair <string, string> >();

            paramList.Add(new KeyValuePair <string, string>("path", encodePath));
            paramList.Add(new KeyValuePair <string, string>("token", _token));
            paramList.Add(new KeyValuePair <string, string>("mount", mount));
            paramList.Add(new KeyValuePair <string, string>("frompath", frompath));
            paramList.Add(new KeyValuePair <string, string>("overwrite", overwrite.ToString()));
            paramList.Add(new KeyValuePair <string, string>("sign", UrlEncoder.Encode(sign)));

            WP7HttpRequest request = new WP7HttpRequest();

            request._httpCompleted += new WP7HttpRequest.HttpResquestEventHandler(handler);
            request.RequestMethod   = RequestType.POST;
            request.RequestUrl      = URL_API + GenerateUrl(signMethod, paramList);
            request.Request();
        }
Esempio n. 5
0
        /// <summary>
        /// 新增文件、文件夹
        /// </summary>
        /// <param name="path">文件路径,文件夹后跟“/”</param>
        /// <param name="mount">mout=gokuai 删除该用户用的存储文件</param>
        /// <param name="filehash">文件hash</param>
        /// <param name="overwrite">上传有同名文件是否覆盖,不传默认0 0覆盖,1新建</param>
        /// <param name="stream"></param>
        /// <param name="handler"></param>
        private void Add(string path, string mount, string filehash, int overwrite, Stream stream, WP7HttpRequest.HttpResquestEventHandler handler)
        {
            long filesize = 0;

            if (stream != null)
            {
                filesize = stream.Length;
                if (filesize > 20 * 1024 * 1024)
                {
                    WP7HttpEventArgs e = new WP7HttpEventArgs();
                    e.Result  = "上传文件超出20MB";
                    e.IsError = true;
                    handler.Invoke(this, e);
                    return;
                }
            }

            string signMethod = "add";
            string sign       = GenerateSign(signMethod, path);
            string encodePath = UrlEncoder.Encode(path);

            List <KeyValuePair <string, string> > paramList = new List <KeyValuePair <string, string> >();

            paramList.Add(new KeyValuePair <string, string>("path", encodePath));
            paramList.Add(new KeyValuePair <string, string>("filehash", filehash));
            paramList.Add(new KeyValuePair <string, string>("token", _token));
            paramList.Add(new KeyValuePair <string, string>("filesize", filesize.ToString()));
            paramList.Add(new KeyValuePair <string, string>("overwrite", overwrite.ToString()));
            paramList.Add(new KeyValuePair <string, string>("sign", UrlEncoder.Encode(sign)));

            WP7HttpRequest request = new WP7HttpRequest();

            request._httpCompleted += new WP7HttpRequest.HttpResquestEventHandler(handler);
            request.RequestMethod   = RequestType.PUT;
            request.UploadStream    = stream;
            request.RequestUrl      = URL_API + GenerateUrl(signMethod, paramList);
            request.Request();
        }