qiniu-spring-boot-starter

Demo project for Spring Boot

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

cn.yunlingfly
ArtifactId

ArtifactId

qiniu-spring-boot-starter
Last Version

Last Version

0.2-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

qiniu-spring-boot-starter
Demo project for Spring Boot
Project URL

Project URL

https://projects.spring.io/spring-boot/#/spring-boot-starter-parent/qiniu-spring-boot-starter
Source Code Management

Source Code Management

https://github.com/Yunlingfly/qiniu-starter.git

Download qiniu-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/cn.yunlingfly/qiniu-spring-boot-starter/ -->
<dependency>
    <groupId>cn.yunlingfly</groupId>
    <artifactId>qiniu-spring-boot-starter</artifactId>
    <version>0.2-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/cn.yunlingfly/qiniu-spring-boot-starter/
implementation 'cn.yunlingfly:qiniu-spring-boot-starter:0.2-RELEASE'
// https://jarcasting.com/artifacts/cn.yunlingfly/qiniu-spring-boot-starter/
implementation ("cn.yunlingfly:qiniu-spring-boot-starter:0.2-RELEASE")
'cn.yunlingfly:qiniu-spring-boot-starter:jar:0.2-RELEASE'
<dependency org="cn.yunlingfly" name="qiniu-spring-boot-starter" rev="0.2-RELEASE">
  <artifact name="qiniu-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.yunlingfly', module='qiniu-spring-boot-starter', version='0.2-RELEASE')
)
libraryDependencies += "cn.yunlingfly" % "qiniu-spring-boot-starter" % "0.2-RELEASE"
[cn.yunlingfly/qiniu-spring-boot-starter "0.2-RELEASE"]

Dependencies

compile (5)

Group / Artifact Type Version
org.springframework.boot : spring-boot-configuration-processor Optional jar 2.0.4.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 2.0.4.RELEASE
com.alibaba : fastjson jar 1.2.10
org.springframework.boot : spring-boot-starter jar 2.0.4.RELEASE
com.qiniu : qiniu-java-sdk jar 7.1.0

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar 2.0.4.RELEASE

Project Modules

There are no modules declared in this project.

qiniu-spring-boot-starter

制作by: yunlingfly@CSDN

博客:https://blog.csdn.net/weixin_38187317/article/details/82723758

2019-3-24 已更新0.2-RELEASE新增获取getUploadToken()方法

引入方式:

<!-- https://mvnrepository.com/artifact/cn.yunlingfly/qiniu-spring-boot-starter -->
<dependency>
	<groupId>cn.yunlingfly</groupId>
	<artifactId>qiniu-spring-boot-starter</artifactId>
	<version>0.2-RELEASE</version>
</dependency>

使用:

修改application.yml添加一下参数:

qiniu:
  secret-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  access-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  bucket-name: xxxx

Controller里引用接口:

@Autowired
IQiniuService qiniuService;

@RequestMapping(value = "qiniu",method = RequestMethod.GET)
public String hello(){
    try {
        qiniuService.uploadFile("images/1.png","1.png",true);
    }catch (QiniuException e){
        e.printStackTrace();
        return "failed";
    }
    return "success";
}

目前版本qiniuService有四个方法:

    /**
     * 上传文件
     * <p>文件上传</p>
     *
     * @param file 填写上传文件File类型
     * @param key 添加上传的key值
     * @param existed 是否已经存在
     * @return 返回com.qiniu.http.Response
     * @throws QiniuException 抛出QiniuException异常
     */
    Response uploadFile(File file, String key, boolean existed) throws QiniuException;

    /**
     * 上传文件
     * <p>文件路径上传</p>
     *
     * @param filePath 填写上传文件的位置
     * @param key 添加上传的key值
     * @param existed 是否已经存在
     * @return 返回com.qiniu.http.Response
     * @throws QiniuException 抛出QiniuException异常
     */
    Response uploadFile(String filePath, String key, boolean existed) throws QiniuException;

    /**
     * 删除
     *
     * @param key 添加上传的key值
     * @throws QiniuException 抛出QiniuException异常
     */
    void deleteFile(String key) throws QiniuException;

    /**
     * 获取上传token
     * <p>获取token</p>
     *
     * @return 返回String
     * @throws QiniuException 抛出QiniuException异常
     */
    String getUploadToken() throws QiniuException;

Versions

Version
0.2-RELEASE
0.1-RELEASE
0.0.1-RELEASE