Seven cattle cloud storage Quick Start

In this article you can learn how to use seven cattle cloud storage (10G the following free !!!) registered seven cattle cloud account first went to seven cattle cloud official register an account -> seven cattle cloud official , after the registration is completed, click personal resources



personal Center

 

  • Then authentication, this authentication does not go into detail here (this should be able to shoot upload ID card, the authentication is completed 1-2 days).


  • Once authentication is complete, then click on the object store, and then create storage space for


    storage space
     


  • Then enter an interface that allows you to enter the name of the space as well as storage areas, as well as access control, space to write their own name to remember on the line, according to a storage area on the area you want to (I am a southerner I chose South China, no other the reason, wanted to look wayward), access control is not necessary if you choose public space (on individual circumstances). Picture the following:
     


    New storage space

     

The above requirements are ready, then you can start using seven cattle cloud save something, take Java to store pictures, the first to introduce the following libraries in Maven here
<!--七牛服务器-->        <dependency>            <groupId>com.qiniu</groupId>            <artifactId>qiniu-java-sdk</artifactId>            <version>7.2.11</version>            <scope>compile</scope>        </dependency>        <dependency>            <groupId>com.squareup.okhttp3</groupId>            <artifactId>okhttp</artifactId>            <version>3.3.1</version>            <scope>compile</scope>        </dependency>        <dependency>            <groupId>com.google.code.gson</groupId>            <artifactId>gson</artifactId>            <version>2.6.2</version>            <scope>compile</scope>        </dependency>        <dependency>            <groupId>com.qiniu</groupId>            <artifactId>happy-dns-java</artifactId>            <version>0.1.4</version>            <scope>compile</scope>        </dependency>        <dependency>            <groupId>com.squareup.okhttp3</groupId>            <artifactId>okhttp</artifactId>            <version>3.3.1</version>            <scope>compile</scope>        </dependency>        <dependency>            <groupId>com.google.code.gson</groupId>            <artifactId>gson</artifactId>            <version>2.6.2</version>            <scope>compile</scope>        </dependency>        <!-- 请求头参数分析包 -->        <dependency>            <groupId>eu.bitwalker</groupId>            <artifactId>UserAgentUtils</artifactId>            <version>1.20</version>        </dependency>        <!--七牛云上传图片服务-->        <dependency>            <groupId>com.qiniu</groupId>            <artifactId>sdk</artifactId>            <version>6.1.0</version>        </dependency>

  • And then define a utility class, to hold seven cattle cloud AK and SK information

  / * ** Description role categories: class name * Created: 2018/12/1 17:54 * constructor arguments: * Modified: 2018/12/1 17:54 * Creator: * Fully qualified class name ZENG: com.hyxiaojingyu.common.VariableName ** / public class VariableName {// seven cattle AK public static final String accessKey = "XXXXXXXXXXXXXXXXXXXXXXXX"; // seven cattle SK public static final String secretKey = "XXXXXXXXXXXXXXXXXXXXXXXXX"; // seven cattle storage space name public static final String bucket = "XXXX"; // default domain of cattle seven public static final String domain = "http: / *******************";} 4.1 ak and sk are available in individual centers - default domain name> to get the key management, bucket is actually the name of your storage space, and seven for cattle is, as shown:

 

 



Key Management

 

 



bucket

 

 



Seven cattle cloud default domain
 

  • And then define a seven cattle cloud tools to upload

/ ** * Class action description: upload pictures to the server * Created: 2018/12/1 17:54 * constructor parameters: * Modified: 2018/12/1 17:54 * Creator: ZENG * fully qualified class name: com.hyxiaojingyu.common.QiniuUpload ** / public class QiniuUpload {// set up the account ACCESS_KEY and SECRET_KEY private static String ACCESS_KEY = VariableName.accessKey; // these two accounts to log seven cattle which can be found private static String SECRET_KEY = VariableName.secretKey; // to upload space private static String bucketname = VariableName.bucket; // corresponds to upload to your path that seven cattle (to build their own set public folders Note) // key configurations private static Auth auth = Auth.create (ACCESS_KEY, SECRET_KEY); private static Configuration cfg = new Configuration (Zone.huanan ()); // create objects uploading private static UploadManager uploadManager = new UploadManager (cfg); // simple upload, using the default policy Simply set the upload space name on it public static String getUpTok en () {return auth.uploadToken (bucketname);
updateFile (MultipartFile file, String filename) , this method is to upload according Spring MVC style MultipartFile types of pictures, and the second parameter is the name of the picture stored in the space of seven cattle cloud.
Completion of the above steps, you can upload pictures to achieve a return address value of the picture of these two methods, you can copy directly to the browser preview. As long as the tools above information is correct, and upload pictures is very convenient, and relatively large free space is recommended.


Author: ariazeng
link: https://www.jianshu.com/p/534389b59732

More learning materials may be concerned about: itheimaGZ get

Published 731 original articles · won praise 3 · Views 110,000 +

Guess you like

Origin blog.csdn.net/u010395024/article/details/104791205