com.aliyun.oss.model.Bucket Java Examples
The following examples show how to use
com.aliyun.oss.model.Bucket.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OssClientWrapper.java From onetwo with Apache License 2.0 | 6 votes |
public Optional<Bucket> getBucket(String bucketName, boolean createIfNotExist) { Bucket bucket = null; if (!ossClient.doesBucketExist(bucketName)) { if(!createIfNotExist){ return Optional.empty(); } /* * Create a new OSS bucket */ if(logger.isInfoEnabled()){ logger.info("Creating bucket {}", bucketName); } // ossClient.createBucket(bucketName); CreateBucketRequest createBucketRequest= new CreateBucketRequest(bucketName); createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead); bucket = ossClient.createBucket(createBucketRequest); }else{ bucket = ossClient.getBucketInfo(bucketName).getBucket(); } return Optional.ofNullable(bucket); }
Example #2
Source File: ApiBootOssOverrideService.java From api-boot with Apache License 2.0 | 5 votes |
/** * 创建bucket存储 * * @param bucketName 存储名称 */ public void createBucket(String bucketName) { OSSClient ossClient = getOssClient(); Bucket bucket = ossClient.createBucket(bucketName); logger.info("新创建存储空间名称:{}", bucket.getName()); logger.info("新创建存储空间所属人:{}", bucket.getOwner().getDisplayName()); closeOssClient(ossClient); }
Example #3
Source File: OssClientWrapperTest.java From onetwo with Apache License 2.0 | 5 votes |
@Test public void listBuckets(){ System.out.println("Listing buckets"); for (Bucket bucket : wraper.listBuckets()) { System.out.println(" - " + bucket.getName()); } System.out.println(); }
Example #4
Source File: AliyunFileStorage.java From cola-cloud with MIT License | 4 votes |
@Override public String getDownloadUrl(String key) { BucketInfo bucketInfo = ossClient.getBucketInfo(this.getBucketName()); Bucket bucket = bucketInfo.getBucket(); return "http://" + bucket.getName() + "." + bucket.getExtranetEndpoint() + "/" + key; }
Example #5
Source File: OssClientWrapper.java From onetwo with Apache License 2.0 | 4 votes |
public Bucket createBucketIfNotExists(String bucketName) { return getBucket(bucketName, true).get(); }
Example #6
Source File: OssClientWrapper.java From onetwo with Apache License 2.0 | 4 votes |
public List<Bucket> listBuckets(){ ListBucketsRequest listBucketsRequest = new ListBucketsRequest(); listBucketsRequest.setMaxKeys(500); BucketList buckList = ossClient.listBuckets(listBucketsRequest); return buckList.getBucketList(); }
Example #7
Source File: BucketService.java From cms with Apache License 2.0 | 2 votes |
/** * 创建一个Bucket,如果创建成功,则返回新的Bucket <br> * * Bucket命名规则:<br> * 只能包括小写字母,数字,短横线(-) <br> * 必须以小写字母或者数字开头 <br> * 长度必须在3-63字节之间 * @param bucketName * @return */ Bucket create(String bucketName);
Example #8
Source File: BucketService.java From cms with Apache License 2.0 | 2 votes |
/** * 列出用户所有的Bucket * @return */ List<Bucket> list() ;