首页 > 大神来看下,关于saveas的问题

大神来看下,关于saveas的问题

报400错误,把url复制到浏览器打开却正常
public static string WebRequest(string url, string method, int timeout, string poststr)
{
try
{
HttpWebRequest req = HttpWebRequest.Create(url) as HttpWebRequest;

            req.Method = method;
            req.Timeout = timeout;

            if (method.ToLower() == "post")
            {
                Stream postStream = req.GetRequestStream();
                byte[] postBytes = Encoding.UTF8.GetBytes(poststr);
                postStream.Write(postBytes, 0, postBytes.Length);
                postStream.Flush();
                postStream.Close();
            }

            HttpWebResponse response = req.GetResponse() as HttpWebResponse;
            Stream responseStream = response.GetResponseStream();
            StreamReader sr = new StreamReader(responseStream);
            string result = sr.ReadToEnd();
            sr.Close();
            responseStream.Close();
            return result;
        }
        catch(Exception EX)
        {
            Console.WriteLine(EX.Message + "}}" + EX.StackTrace);
            return string.Empty;
        }
    }

string saveas = "cjuserhead:asdf.jpg";
saveas = Qiniu.Util.Base64URLSafe.Encode(saveas);
string tosign = "cjuserhead.qiniudn.com/11.jpg?imageView2/1/w/200/h/200|saveas/" + saveas;
HMACSHA1 sha1 = new HMACSHA1(Encoding.UTF8.GetBytes(sk));
string sign = Qiniu.Util.Base64URLSafe.Encode(sha1.ComputeHash(Encoding.UTF8.GetBytes(tosign)));
string url = "http://cjuserhead.qiniudn.com/11.jpg?imageView2/1/w/200/h/200|saveas/" + saveas + "/sign/" + ak + ":" + sign;
string r = WebRequest(url, "get", 20000, "");

【热门文章】
【热门文章】