Skip to content

Commit c38a46a

Browse files
authored
Merge pull request #188 from tencentyun/dev/update_demo
Dev/update demo
2 parents 635de09 + 7de67a4 commit c38a46a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+209
-227
lines changed

src/main/java/com/qcloud/cos/demo/AppendObjectDemo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
import java.io.InputStream;
1515

1616
public class AppendObjectDemo {
17-
public static void AppendObjectFromLocal() {
17+
public static void appendObjectFromLocal() {
1818
// 1 初始化用户身份信息(secretId, secretKey)
1919
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
2020
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
2121
ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
2222
// 3 生成cos客户端
2323
COSClient cosclient = new COSClient(cred, clientConfig);
2424
// bucket名需包含appid
25-
String bucketName = "mybucket-1251668577";
25+
String bucketName = "mybucket-12500000000";
2626
String key = "aaa/bbb.txt";
2727
try {
2828
File localFile = new File("1M.txt");
@@ -48,6 +48,6 @@ public static void AppendObjectFromLocal() {
4848
}
4949

5050
public static void main(String[] args) {
51-
AppendObjectFromLocal();
51+
appendObjectFromLocal();
5252
}
5353
}

src/main/java/com/qcloud/cos/demo/AsymmetricKeyEncryptionClientDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class AsymmetricKeyEncryptionClientDemo {
4141
private static final String priKeyPath = "pri.key";
4242
private static final SecureRandom srand = new SecureRandom();
4343

44-
static String bucketName = "mybucket-1251668577";
44+
static String bucketName = "mybucket-12500000000";
4545
static String key = "testKMS/asy.txt";
4646
static File localFile = new File("len1m.txt");
4747

src/main/java/com/qcloud/cos/demo/BucketCertificateDemo.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
import com.qcloud.cos.region.Region;
1212
import com.qcloud.cos.utils.StringUtils;
1313

14-
import java.io.*;
14+
import java.io.BufferedReader;
15+
import java.io.FileInputStream;
16+
import java.io.IOException;
17+
import java.io.InputStream;
18+
import java.io.InputStreamReader;
1519
import java.util.LinkedList;
1620
import java.util.List;
1721

@@ -23,7 +27,7 @@ public static void putGetDeleteBucketCertificate() {
2327
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
2428
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing"));
2529
// bucket名需包含appid
26-
String bucketName = "mybucket-1251668577";
30+
String bucketName = "mybucket-12500000000";
2731

2832
BucketPutDomainCertificate bucketPutDomainCertificate = new BucketPutDomainCertificate();
2933
BucketDomainCertificateInfo bucketDomainCertificateInfo = new BucketDomainCertificateInfo();

src/main/java/com/qcloud/cos/demo/BucketDemo.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
*/
2828
public class BucketDemo {
2929
// 创建bucket
30-
public static void CreateBucketDemo() {
30+
public static void createBucketDemo() {
3131
// 1 初始化用户身份信息(appid, secretId, secretKey)
3232
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
3333
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
3434
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
3535
// 3 生成cos客户端
3636
COSClient cosclient = new COSClient(cred, clientConfig);
3737
// bucket名称, 需包含appid
38-
String bucketName = "publicreadbucket-1251668577";
38+
String bucketName = "publicreadbucket-12500000000";
3939

4040
CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
4141
// 设置bucket的权限为PublicRead(公有读私有写), 其他可选有私有读写, 公有读私有写
@@ -47,15 +47,15 @@ public static void CreateBucketDemo() {
4747
}
4848

4949
// 开启 bucket 版本控制
50-
public static void SetBucketVersioning() {
50+
public static void setBucketVersioning() {
5151
// 1 初始化用户身份信息(appid, secretId, secretKey)
5252
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
5353
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
5454
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
5555
// 3 生成cos客户端
5656
COSClient cosclient = new COSClient(cred, clientConfig);
5757
// bucket名称, 需包含appid
58-
String bucketName = "examplebucket-1251668577";
58+
String bucketName = "examplebucket-12500000000";
5959

6060
// 开启版本控制
6161
BucketVersioningConfiguration bucketVersioningConfiguration = new BucketVersioningConfiguration(BucketVersioningConfiguration.ENABLED);
@@ -68,15 +68,15 @@ public static void SetBucketVersioning() {
6868
}
6969

7070
// 开启日志存储
71-
public static void SetBucketLogging() {
71+
public static void setBucketLogging() {
7272
// 1 初始化用户身份信息(appid, secretId, secretKey)
7373
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
7474
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
7575
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
7676
// 3 生成cos客户端
7777
COSClient cosclient = new COSClient(cred, clientConfig);
7878
// bucket名称, 需包含appid
79-
String bucketName = "examplebucket-1251668577";
79+
String bucketName = "examplebucket-12500000000";
8080

8181
BucketLoggingConfiguration bucketLoggingConfiguration = new BucketLoggingConfiguration();
8282
// 设置日志存储的 bucket
@@ -89,15 +89,15 @@ public static void SetBucketLogging() {
8989
}
9090

9191
// 使用 bucket tag
92-
public static void SetGetDeleteBucketTagging() {
92+
public static void setGetDeleteBucketTagging() {
9393
// 1 初始化用户身份信息(secretId, secretKey)
9494
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
9595
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
9696
ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
9797
// 3 生成cos客户端
9898
COSClient cosclient = new COSClient(cred, clientConfig);
9999
// bucket名需包含appid
100-
String bucketName = "mybucket-1251668577";
100+
String bucketName = "mybucket-12500000000";
101101
List<TagSet> tagSetList = new LinkedList<TagSet>();
102102
TagSet tagSet = new TagSet();
103103
tagSet.setTag("age", "18");
@@ -114,15 +114,15 @@ public static void SetGetDeleteBucketTagging() {
114114
}
115115

116116
// 删除bucket, 只用于空bucket, 含有数据的bucket需要在删除前清空删除。
117-
public static void DeleteBucketDemo() {
117+
public static void deleteBucketDemo() {
118118
// 1 初始化用户身份信息(appid, secretId, secretKey)
119119
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
120120
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
121121
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
122122
// 3 生成cos客户端
123123
COSClient cosclient = new COSClient(cred, clientConfig);
124124
// bucket名称, 需包含appid
125-
String bucketName = "publicreadbucket-1251668577";
125+
String bucketName = "publicreadbucket-12500000000";
126126
// 删除bucket
127127
cosclient.deleteBucket(bucketName);
128128

@@ -131,23 +131,23 @@ public static void DeleteBucketDemo() {
131131
}
132132

133133
// 查询bucket是否存在
134-
public static void JudgeBucketExistDemo() {
134+
public static void judgeBucketExistDemo() {
135135
// 1 初始化用户身份信息(appid, secretId, secretKey)
136136
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
137137
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
138138
ClientConfig clientConfig = new ClientConfig(new Region("ap-beijing-1"));
139139
// 3 生成cos客户端
140140
COSClient cosclient = new COSClient(cred, clientConfig);
141141

142-
String bucketName = "publicreadbucket-1251668577";
142+
String bucketName = "publicreadbucket-12500000000";
143143
// 判断bucket是否存在
144144
cosclient.doesBucketExist(bucketName);
145145

146146
// 关闭客户端
147147
cosclient.shutdown();
148148
}
149149

150-
public static void ListBuckets() {
150+
public static void listBuckets() {
151151
// 1 初始化用户身份信息(appid, secretId, secretKey)
152152
COSCredentials cred = new BasicCOSCredentials("AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "****************************");
153153
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
@@ -167,15 +167,15 @@ public static void ListBuckets() {
167167
}
168168

169169
//创多AZ桶
170-
public static void CreateMAZBucketDemo() {
170+
public static void createMAZBucketDemo() {
171171
// 1 初始化用户身份信息(appid, secretId, secretKey)
172172
COSCredentials cred = new BasicCOSCredentials("AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "****************************");
173173
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
174174
ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
175175
// 3 生成cos客户端
176176
COSClient cosclient = new COSClient(cred, clientConfig);
177177

178-
String bucketname = "publicreadbucket-1251668577";
178+
String bucketname = "publicreadbucket-12500000000";
179179
CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketname);
180180

181181
try {
@@ -189,6 +189,6 @@ public static void CreateMAZBucketDemo() {
189189
}
190190
}
191191
public static void main(String[] args) {
192-
ListBuckets();
192+
listBuckets();
193193
}
194194
}

src/main/java/com/qcloud/cos/demo/BucketDomainDemo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
import com.qcloud.cos.region.Region;
1010

1111
public class BucketDomainDemo {
12-
public static void SetGetDeleteBucketDomainDemo() {
12+
public static void setGetDeleteBucketDomainDemo() {
1313
// 1 初始化用户身份信息(secretId, secretKey)
1414
COSCredentials cred = new BasicCOSCredentials("AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
1515
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
1616
ClientConfig clientConfig = new ClientConfig(new Region("ap-shanghai"));
1717
// 3 生成cos客户端
1818
COSClient cosclient = new COSClient(cred, clientConfig);
1919
// bucket名需包含appid
20-
String bucketName = "mybucket-1251668577";
20+
String bucketName = "mybucket-12500000000";
2121
BucketDomainConfiguration bucketDomainConfiguration = new BucketDomainConfiguration();
2222
DomainRule domainRule = new DomainRule();
2323
domainRule.setStatus(DomainRule.ENABLED);
@@ -42,6 +42,6 @@ public static void SetGetDeleteBucketDomainDemo() {
4242
}
4343

4444
public static void main(String[] args) {
45-
SetGetDeleteBucketDomainDemo();
45+
setGetDeleteBucketDomainDemo();
4646
}
4747
}

src/main/java/com/qcloud/cos/demo/BucketIntelligentTierDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void main(String[] args) {
1818
// 3 生成cos客户端
1919
COSClient cosclient = new COSClient(cred, clientConfig);
2020
// bucket名需包含appid
21-
String bucketName = "mybucket-1251668577";
21+
String bucketName = "mybucket-12500000000";
2222

2323
BucketIntelligentTierConfiguration bucketIntelligentTierConfiguration = new BucketIntelligentTierConfiguration();
2424
bucketIntelligentTierConfiguration.setStatus(BucketIntelligentTierConfiguration.ENABLED);

src/main/java/com/qcloud/cos/demo/BucketInventoryDemo.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
import java.util.List;
1414

1515
public class BucketInventoryDemo {
16-
public static void SetGetDeleteBucketInventoryDemo() {
16+
public static void setGetDeleteBucketInventoryDemo() {
1717
// 1 初始化用户身份信息(secretId, secretKey)
1818
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
1919
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
2020
ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
2121
// 3 生成cos客户端
2222
COSClient cosclient = new COSClient(cred, clientConfig);
2323
// bucket名需包含appid
24-
String bucketName = "mybucket-1251668577";
24+
String bucketName = "mybucket-12500000000";
2525

2626
InventoryConfiguration inventoryConfiguration = new InventoryConfiguration();
2727
InventoryCosBucketDestination inventoryCosBucketDestination = new InventoryCosBucketDestination();
2828
// 设置清单的输出目标存储桶的格式和前缀等
2929
inventoryCosBucketDestination.setAccountId("2779643970");
30-
inventoryCosBucketDestination.setBucketArn("qcs::cos:ap-guangzhou::mybucket-1251668577");
30+
inventoryCosBucketDestination.setBucketArn("qcs::cos:ap-guangzhou::mybucket-12500000000");
3131
inventoryCosBucketDestination.setEncryption(new ServerSideEncryptionCOS());
3232
inventoryCosBucketDestination.setFormat(InventoryFormat.CSV);
3333
inventoryCosBucketDestination.setPrefix("inventory-output");
@@ -73,15 +73,15 @@ public static void SetGetDeleteBucketInventoryDemo() {
7373
cosclient.deleteBucketInventoryConfiguration(deleteBucketInventoryConfigurationRequest);
7474
}
7575

76-
public static void SetBucketInventoryDemo() {
76+
public static void setBucketInventoryDemo() {
7777
// 1 初始化用户身份信息(secretId, secretKey)
7878
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
7979
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
8080
ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
8181
// 3 生成cos客户端
8282
COSClient cosclient = new COSClient(cred, clientConfig);
8383
// bucket名需包含appid
84-
String bucketName = "mybucket-1251668577";
84+
String bucketName = "mybucket-12500000000";
8585

8686
SetBucketInventoryConfigurationRequest request = new SetBucketInventoryConfigurationRequest();
8787
request.setBucketName(bucketName);
@@ -100,7 +100,7 @@ public static void SetBucketInventoryDemo() {
100100
"<Destination>\n" +
101101
"<COSBucketDestination>\n" +
102102
"<AccountId>2779643970</AccountId>\n" +
103-
"<Bucket>qcs::cos:ap-guangzhou::mybucket-1251668577</Bucket>\n" +
103+
"<Bucket>qcs::cos:ap-guangzhou::mybucket-12500000000</Bucket>\n" +
104104
"<Prefix>inventory-output</Prefix>\n" +
105105
"<Format>CSV</Format>\n" +
106106
"<Encryption><SSECOS></SSECOS></Encryption>\n" +
@@ -128,7 +128,7 @@ public static void SetBucketInventoryDemo() {
128128
}
129129

130130
public static void main(String[] args) {
131-
SetGetDeleteBucketInventoryDemo();
132-
SetBucketInventoryDemo();
131+
setGetDeleteBucketInventoryDemo();
132+
setBucketInventoryDemo();
133133
}
134134
}

src/main/java/com/qcloud/cos/demo/BucketLifecycleDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
public class BucketLifecycleDemo {
20-
public String bucketName = "example-1251668577";
20+
public String bucketName = "example-12500000000";
2121
public COSClient cosClient = COSBuilder();
2222

2323
public COSClient COSBuilder() {

src/main/java/com/qcloud/cos/demo/BucketLoggingDemo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
import com.qcloud.cos.region.Region;
99

1010
public class BucketLoggingDemo {
11-
public static void SetGetBucketLoggingDemo() {
11+
public static void setGetBucketLoggingDemo() {
1212
// 1 初始化用户身份信息(secretId, secretKey)
1313
COSCredentials cred = new BasicCOSCredentials("AKIDXXXXXXXX", "1A2Z3YYYYYYYYYY");
1414
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
1515
ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
1616
// 3 生成cos客户端
1717
COSClient cosclient = new COSClient(cred, clientConfig);
1818
// bucket名需包含appid
19-
String bucketName = "mybucket-1251668577";
19+
String bucketName = "mybucket-12500000000";
2020
BucketLoggingConfiguration bucketLoggingConfiguration = new BucketLoggingConfiguration();
2121
bucketLoggingConfiguration.setDestinationBucketName(bucketName);
2222
bucketLoggingConfiguration.setLogFilePrefix("logs");
@@ -26,6 +26,6 @@ public static void SetGetBucketLoggingDemo() {
2626
BucketLoggingConfiguration bucketLoggingConfiguration1 = cosclient.getBucketLoggingConfiguration(bucketName);
2727
}
2828
public static void main(String[] args) {
29-
SetGetBucketLoggingDemo();
29+
setGetBucketLoggingDemo();
3030
}
3131
}

src/main/java/com/qcloud/cos/demo/BucketPolicyDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
public class BucketPolicyDemo {
12-
public static void SetGetBucketPolicy() {
12+
public static void setGetBucketPolicy() {
1313
// 1 初始化用户身份信息(secretId, secretKey)
1414
COSCredentials cred = new BasicCOSCredentials("SECRET_ID", "SECRET_KEY");
1515
// 2 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
@@ -42,7 +42,7 @@ public static void SetGetBucketPolicy() {
4242
System.out.println(bucketPolicy.getPolicyText());
4343
}
4444
public static void main(String[] args) {
45-
SetGetBucketPolicy();
45+
setGetBucketPolicy();
4646
}
4747
}
4848

0 commit comments

Comments
 (0)