Qiniu Seven cow problem solution
Seven Bull Management interface example, interested can write their own seven cattle management Demao
The Java code for the problem solution delete interface is as follows:
//ak,sk need to go to the seven bull backstage secret key to get. Public string Delete(stringEncodeurl) {stringAccesstoken =""; Stream OutStream =NULL;stringGETURL ="http //"+"Rs.qiniu.com"+"/delete/"+ Encodeurl;//Use the Create method of the HttpWebRequest class to make a request to the URI object. HttpWebRequest request = (HttpWebRequest) httpwebrequest.create (GETURL);//Specify the mode of the request as Get modeRequest. Method = WebRequestMethods.Http.Post; Request. Host ="Rs.qiniu.com"; Request. ContentType ="application/x-www-form-urlencoded"; Accesstoken = Getaccesssign ("/delete/"+ encodeurl+"\ n"); Request. Headers.add ("Authorization","QBox"+ Accesstoken); OutStream = Request. GetRequestStream (); OutStream. Close ();//Gets the resource that the request responds to and strongly transitions to the HttpWebResponse response objectHttpWebResponse response = (HttpWebResponse) request. GetResponse ();//Gets the readable stream of the response objectStreamReader reader =NewStreamReader (response. GetResponseStream ());//Stream text read completed and assigned to STR stringstr = reader. ReadToEnd ();//Turn off responseResponse. Close ();returnSTR;}Private string getaccesssign(strings) {byte[] Bytesnewurl = This. Myencoding.getbytes (s);byte[] Bytessk = This. Myencoding.getbytes (SK); System.Security.Cryptography.HMACSHA1 HMAC =NewSystem.Security.Cryptography.HMACSHA1 (BYTESSK);byte[] Digest = Hmac.computehash (Bytesnewurl);stringSign = convert.tobase64string (digest); Sign = sign. Replace (' + ','-'). Replace ('/',' _ ');stringFinalURL = AK +":"+ sign;returnFinalURL;}
Results Demo
This is not a demonstration, the main is to let seven customers can have their own written seven ox SDK capabilities. Can be skilled in the use of seven of cattle services, seven of cattle most of the service needs some code-capable programmers to write the use.
License
Copyright (c) qiniu.com
The management voucher of seven cows how to write your own--delete interface Java implementation