Skip to content

Commit cc76994

Browse files
authored
Merge branch 'master' into QRTC-1875
2 parents ff4f3e5 + 0f9fd41 commit cc76994

File tree

5 files changed

+122
-1
lines changed

5 files changed

+122
-1
lines changed

.codebeatsettings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"JAVA": {
3+
"TOO_MANY_IVARS": [8, 15, 20, 25],
4+
"ARITY": [5, 10, 15, 20]
5+
}
6+
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
3+
## 7.10.1 (2022-04-25)
4+
* 对象存储,补充 stat api 可查看对象元数据信息
5+
26
## 7.10.0 (2022-04-15)
37
* 对象存储,新增支持 [深度归档存储类型](https://developer.qiniu.com/kodo/3956/kodo-category#deep_archive)
48

src/main/java/com/qiniu/common/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public final class Constants {
99
/**
1010
* 版本号
1111
*/
12-
public static final String VERSION = "7.10.0";
12+
public static final String VERSION = "7.10.1";
1313
/**
1414
* 块大小,不能改变
1515
*/

src/main/java/com/qiniu/storage/model/FileInfo.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ public final class FileInfo {
3030
*/
3131
public long putTime;
3232

33+
/**
34+
* 归档/深度归档存储文件的解冻状态,归档/深度归档文件冻结时,不返回该字段。
35+
* 1 表示解冻中
36+
* 2 表示解冻完成
37+
*/
38+
public Integer restoreStatus;
39+
3340
/**
3441
* 文件的mimeType
3542
*/
@@ -61,6 +68,48 @@ public final class FileInfo {
6168
*/
6269
public String md5;
6370

71+
/**
72+
* 文件过期删除日期,int64 类型,Unix 时间戳格式,具体文件过期日期计算参考 生命周期管理。
73+
* 文件在设置过期时间后才会返回该字段(通过生命周期规则设置文件过期时间,仅对该功能发布后满足规则条件新上传文件返回该字段;
74+
* 历史文件想要返回该字段需要在功能发布后可通过 修改文件过期删除时间 API 或者 修改文件生命周期 API 指定过期时间;对于已
75+
* 经设置过过期时间的历史文件,到期都会正常过期删除,只是服务端没有该字段返回)
76+
*
77+
* 例如:值为1568736000的时间,表示文件会在2019/9/18当天内删除。
78+
*/
79+
public Long expiration;
80+
81+
82+
/**
83+
* 文件生命周期中转为低频存储的日期,int64 类型,Unix 时间戳格式 ,具体日期计算参考 生命周期管理。
84+
* 文件在设置转低频后才会返回该字段(通过生命周期规则设置文件转低频,仅对该功能发布后满足规则条件新上传文件返回该字段;
85+
* 历史文件想要返回该字段需要在功能发布后可通过 修改文件生命周期 API 指定转低频时间;对于已经设置过转低频时间的历史文
86+
* 件,到期都会正常执行,只是服务端没有该字段返回)
87+
*
88+
* 例如:值为1568736000的时间,表示文件会在2019/9/18当天转为低频存储类型。
89+
*/
90+
public Long transitionToIA;
91+
92+
/**
93+
* 文件生命周期中转为归档存储的日期,int64 类型,Unix 时间戳格式 ,具体日期计算参考 生命周期管理。
94+
* 文件在设置转归档后才会返回该字段(通过生命周期规则设置文件转归档,仅对该功能发布后满足规则条件新上传文件返回该字段;
95+
* 历史文件想要返回该字段需要在功能发布后可通过 修改文件生命周期 API 指定转归档时间;对于已经设置过转归档时间的历史文
96+
* 件,到期都会正常执行,只是服务端没有该字段返回)
97+
*
98+
* 例如:值为1568736000的时间,表示文件会在2019/9/18当天转为归档存储类型。
99+
*/
100+
@SerializedName("transitionToARCHIVE")
101+
public Long transitionToArchive;
102+
103+
/**
104+
* 文件生命周期中转为深度归档存储的日期,int64 类型,Unix 时间戳格式 ,具体日期计算参考 生命周期管理。
105+
* 文件在设置转深度归档后才会返回该字段(通过生命周期规则设置文件转深度归档,仅对该功能发布后满足规则条件新上传文件返回该字段;
106+
* 历史文件想要返回该字段需要在功能发布后可通过 修改文件生命周期 API 指定转深度归档时间;对于已经设置过转深度归档时间的历史文
107+
* 件,到期都会正常执行,只是服务端没有该字段返回)
108+
*
109+
* 例如:值为1568736000的时间,表示文件会在2019/9/18当天转为深度归档存储类型。
110+
*/
111+
public Long transitionToDeepArchive;
112+
64113
/**
65114
* 自定义 meta data 数据
66115
*/

src/test/java/test/com/qiniu/storage/BucketTest2.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
import test.com.qiniu.ResCode;
1919
import test.com.qiniu.TestConfig;
2020

21+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
24+
import static org.junit.jupiter.api.Assertions.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertNull;
26+
import static org.junit.jupiter.api.Assertions.assertTrue;
27+
import static org.junit.jupiter.api.Assertions.fail;
28+
2129
import java.io.IOException;
2230
import java.text.SimpleDateFormat;
2331
import java.util.*;
@@ -215,6 +223,60 @@ public void testListMarkerV2() {
215223
@Test
216224
@Tag("IntegrationTest")
217225
public void testStat() {
226+
String ruleName = "javaStatusRule";
227+
String copyKey = TestConfig.testBucket_z0 + "_status_copy";
228+
229+
try {
230+
bucketManager.deleteBucketLifecycleRule(TestConfig.testBucket_z0, ruleName);
231+
} catch (QiniuException e) {
232+
e.printStackTrace();
233+
}
234+
235+
try {
236+
bucketManager.copy(TestConfig.testBucket_z0, TestConfig.testKey_z0, TestConfig.testBucket_z0, copyKey, true);
237+
bucketManager.changeType(TestConfig.testBucket_z0, copyKey, StorageType.Archive);
238+
bucketManager.restoreArchive(TestConfig.testBucket_z0, copyKey, 1);
239+
FileInfo info = bucketManager.stat(TestConfig.testBucket_z0, copyKey);
240+
assertNotNull(info.hash);
241+
assertNotNull(info.mimeType);
242+
assertNotNull(info.restoreStatus);
243+
244+
bucketManager.delete(TestConfig.testBucket_z0, copyKey);
245+
BucketLifeCycleRule rule = new BucketLifeCycleRule(ruleName, "");
246+
rule.setToLineAfterDays(1);
247+
rule.setToArchiveAfterDays(2);
248+
rule.setToDeepArchiveAfterDays(3);
249+
rule.setDeleteAfterDays(4);
250+
bucketManager.putBucketLifecycleRule(TestConfig.testBucket_z0, rule);
251+
bucketManager.copy(TestConfig.testBucket_z0, TestConfig.testKey_z0, TestConfig.testBucket_z0, copyKey, true);
252+
bucketManager.deleteAfterDays(TestConfig.testBucket_z0, copyKey, 1);
253+
info = bucketManager.stat(TestConfig.testBucket_z0, copyKey);
254+
assertNotNull(info.hash);
255+
assertNotNull(info.mimeType);
256+
assertNotNull(info.expiration);
257+
// assertNotNull(info.transitionToIA);
258+
// assertNotNull(info.transitionToArchive);
259+
// assertNotNull(info.transitionToDeepArchive);
260+
} catch (QiniuException e) {
261+
e.printStackTrace();
262+
fail("status change type fail:" + e);
263+
} finally {
264+
try {
265+
bucketManager.deleteBucketLifecycleRule(TestConfig.testBucket_z0, ruleName);
266+
} catch (QiniuException e) {
267+
e.printStackTrace();
268+
}
269+
}
270+
271+
try {
272+
FileInfo info = bucketManager.stat(TestConfig.testBucket_z0, copyKey);
273+
assertNotNull(info.hash);
274+
assertNotNull(info.mimeType);
275+
assertNotNull(info.expiration);
276+
} catch (QiniuException e) {
277+
fail("status fail:" + e);
278+
}
279+
218280
// test exists
219281
Map<String, String> bucketKeyMap = new HashMap<String, String>();
220282
bucketKeyMap.put(TestConfig.testBucket_z0, TestConfig.testKey_z0);

0 commit comments

Comments
 (0)