The management voucher of seven cows how to write your own--delete interface Java implementation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.