An open API service indexing awesome lists of open source software.

https://github.com/qiniu/java-sdk

Qiniu Resource (Cloud) Storage SDK for Java
https://github.com/qiniu/java-sdk

java rtc-sdk storage-sdk

Last synced: 7 months ago
JSON representation

Qiniu Resource (Cloud) Storage SDK for Java

Awesome Lists containing this project

README

          

# Qiniu Resource Storage SDK for Java

[![@qiniu on weibo](http://img.shields.io/badge/weibo-%40qiniutek-blue.svg)](http://weibo.com/qiniutek)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Build Status](https://travis-ci.org/qiniu/java-sdk.svg)](https://travis-ci.org/qiniu/java-sdk)
[![GitHub release](https://img.shields.io/github/v/tag/qiniu/java-sdk.svg?label=release)](https://github.com/qiniu/java-sdk/releases)
[![Docs](https://img.shields.io/github/v/tag/qiniu/java-sdk.svg?label=docs&color=yellow)](https://qiniu.github.io/java-sdk/)
[![Coverage Status](https://codecov.io/gh/qiniu/java-sdk/branch/master/graph/badge.svg)](https://codecov.io/gh/qiniu/java-sdk)
[![Latest Stable Version](https://img.shields.io/maven-central/v/com.qiniu/qiniu-java-sdk.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.qiniu%22%20AND%20a%3A%22qiniu-java-sdk%22)

## 安装

下载 [the latest JAR][1] 或者 通过 Maven:

```xml

com.qiniu
qiniu-java-sdk
[7.18.0, 7.18.99]

```

或者 Gradle:

```groovy
implementation 'com.qiniu:qiniu-java-sdk:7.18.+'
```

## 运行环境

JDK 7 及以上

## 使用方法

### 上传

```Java
// 分片上传 v1
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import com.qiniu.storage.Configuration;
import com.qiniu.http.Response;

String accessKey = "Your AccessKey";
String secretKey = "Your SecretKey";
String bucketName = "upload to bucket";
Configuration cfg = new Configuration();
UploadManager uploadManager = new UploadManager(cfg);
Auth auth = Auth.create(accessKey, secretKey);
String token = auth.uploadToken(bucketName);
String key = "file save key";
Response r = uploadManager.put("hello world".getBytes(), key, token);

// 分片上传 v2
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import com.qiniu.storage.Configuration;
import com.qiniu.http.Response;

String accessKey = "Your AccessKey";
String secretKey = "Your SecretKey";
String bucketName = "upload to bucket";
Configuration cfg = new Configuration();
cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;
UploadManager uploadManager = new UploadManager(cfg);
Auth auth = Auth.create(accessKey, secretKey);
String token = auth.uploadToken(bucketName);
String key = "file save key";
Response r = uploadManager.put("hello world".getBytes(), key, token);
```

其他使用请参考[开发指南]https://developer.qiniu.com/kodo/1239/java
详细的示例请参考[Examples]https://github.com/qiniu/java-sdk/tree/master/examples

## 测试

``` bash
$ ./gradlew build
```

## 生成Eclipse工程文件

``` bash
$ ./gradlew gen_eclipse
```

## 常见问题

- QiniuExeption保留了请求响应的信息,失败情况下会抛出此异常,可以提交给我们排查问题。
- API 的使用 demo 可以参考 [单元测试](https://github.com/qiniu/java-sdk/blob/master/src/test)。

## 代码贡献

详情参考[代码提交指南](https://github.com/qiniu/java-sdk/blob/master/CONTRIBUTING.md)。

## 贡献记录

- [所有贡献者](https://github.com/qiniu/java-sdk/contributors)

## 联系我们

- 如果需要帮助,请提交工单(在portal右侧点击咨询和建议提交工单,或者直接向 support@qiniu.com 发送邮件)
- 如果有什么问题,可以到问答社区提问,[问答社区](http://qiniu.segmentfault.com/)
- 更详细的文档,见[官方文档站](http://developer.qiniu.com/)
- 如果发现了bug, 欢迎提交 [issue](https://github.com/qiniu/java-sdk/issues)
- 如果有功能需求,欢迎提交 [issue](https://github.com/qiniu/java-sdk/issues)
- 如果要提交代码,欢迎提交 pull request
- 欢迎关注我们的[微信](http://www.qiniu.com/#weixin) [微博](http://weibo.com/qiniutek),及时获取动态信息。

## 代码许可

The MIT License (MIT).详情见 [License文件](https://github.com/qiniu/java-sdk/blob/master/LICENSE).

[1]: https://search.maven.org/remote_content?g=com.qiniu&a=qiniu-java-sdk&v=LATEST

[2]: https://github.com/Nextpeer/okhttp

[3]: https://raw.githubusercontent.com/qiniu/java-sdk/master/libs/okhttp-2.3.0-SNAPSHOT.jar

[4]: https://raw.githubusercontent.com/qiniu/java-sdk/master/libs/okio-1.3.0-SNAPSHOT.jar