本文整理汇总了Java中com.aliyun.oss.model.CannedAccessControlList类的典型用法代码示例。如果您正苦于以下问题:Java CannedAccessControlList类的具体用法?Java CannedAccessControlList怎么用?Java CannedAccessControlList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CannedAccessControlList类属于com.aliyun.oss.model包,在下文中一共展示了CannedAccessControlList类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createContainerInLocation
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
@Override
public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
OSS oss = api.getOSSClient(location.getId());
boolean result = true;
try {
CreateBucketRequest req = new CreateBucketRequest(container);
CannedAccessControlList acl = CannedAccessControlList.Private;
if (options.isPublicRead()) {
acl = CannedAccessControlList.PublicRead;
}
req.setCannedACL(acl);
oss.createBucket(req);
} catch (Exception e) {
result = false;
}
return result;
}
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:18,代码来源:OSSBlobStore.java
示例2: AliyunossProvider
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
public AliyunossProvider(String urlprefix,String endpoint, String bucketName, String accessKey, String secretKey,boolean isPrivate) {
Validate.notBlank(endpoint, "[endpoint] not defined");
Validate.notBlank(bucketName, "[bucketName] not defined");
Validate.notBlank(accessKey, "[accessKey] not defined");
Validate.notBlank(secretKey, "[secretKey] not defined");
Validate.notBlank(urlprefix, "[urlprefix] not defined");
ossClient = new OSSClient(endpoint, accessKey, secretKey);
this.bucketName = bucketName;
this.urlprefix = urlprefix.endsWith("/") ? urlprefix : (urlprefix + "/");
this.isPrivate = isPrivate;
if (!ossClient.doesBucketExist(bucketName)) {
System.out.println("Creating bucket " + bucketName + "\n");
ossClient.createBucket(bucketName);
CreateBucketRequest createBucketRequest= new CreateBucketRequest(bucketName);
createBucketRequest.setCannedACL(isPrivate ? CannedAccessControlList.Private : CannedAccessControlList.PublicRead);
ossClient.createBucket(createBucketRequest);
}
}
开发者ID:vakinge,项目名称:jeesuite-libs,代码行数:21,代码来源:AliyunossProvider.java
示例3: getBucket
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
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);
}
开发者ID:wayshall,项目名称:onetwo,代码行数:22,代码来源:OssClientWrapper.java
示例4: createBucket
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
/**
* 创建bucket,阿里设定最多10个bucketName
* @param bucketName bucket名称
* @param isPublic 是否可以公开访问
*/
public void createBucket(OSSClient ossClient, String bucketName, Boolean isPublic){
boolean hasExists = ossClient.doesBucketExist(bucketName);
if (!hasExists) {
// 新建一个Bucket
ossClient.createBucket(bucketName);
// 设置操作权限对外公开
ossClient.setBucketAcl(bucketName, isPublic? CannedAccessControlList.PublicRead: CannedAccessControlList.Private);
}
}
开发者ID:lemon-china,项目名称:lemon-fileservice,代码行数:15,代码来源:FileUploadService.java
示例5: OSSBlobStore
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
@Inject
protected OSSBlobStore(
OSSApi api,
BlobStoreContext context,
BlobUtils blobUtils,
Supplier<Location> defaultLocation,
LocationsSupplier locations,
Supplier<Map<ContainerAccess, CannedAccessControlList>> bucketAccesses,
Supplier<Map<BlobAccess, CannedAccessControlList>> blobAccesses) {
super(context, blobUtils, defaultLocation, locations);
this.api = api;
this.bucketAccesses = bucketAccesses.get();
this.blobAccesses = blobAccesses.get();
}
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:15,代码来源:OSSBlobStore.java
示例6: accessFromBlobToOSS
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
@Provides
@Singleton
protected final Supplier<Map<BlobAccess, CannedAccessControlList>> accessFromBlobToOSS() {
Map<BlobAccess, CannedAccessControlList> regions = ImmutableMap
.<BlobAccess, CannedAccessControlList>builder()
.put(BlobAccess.PRIVATE, CannedAccessControlList.Private)
.put(BlobAccess.PUBLIC_READ, CannedAccessControlList.PublicRead)
.build();
return Suppliers.ofInstance(regions);
}
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:11,代码来源:OSSBlobStoreContextModule.java
示例7: accessFromContainerToOSS
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
@Provides
@Singleton
protected final Supplier<Map<ContainerAccess, CannedAccessControlList>> accessFromContainerToOSS() {
Map<ContainerAccess, CannedAccessControlList> regions = ImmutableMap
.<ContainerAccess, CannedAccessControlList>builder()
.put(ContainerAccess.PRIVATE, CannedAccessControlList.Private)
.put(ContainerAccess.PUBLIC_READ, CannedAccessControlList.PublicRead)
.build();
return Suppliers.ofInstance(regions);
}
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:11,代码来源:OSSBlobStoreContextModule.java
示例8: accessKeySave
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
/**
* 第三步,验证AccessKey的id、screct的有效性,并初始化创建OSS
*/
@RequestMapping("/accessKeySave")
@ResponseBody
public BaseVO accessKeySave(
@RequestParam(value = "id", required = false, defaultValue="") String id,
@RequestParam(value = "secret", required = false, defaultValue="") String secret
){
if(!Global.get("IW_AUTO_INSTALL_USE").equals("true")){
return error("系统已禁止使用此!");
}
if(id.length() == 0){
return error("请输入 Access Key ID");
}
if(secret.length() == 0){
return error("请输入 Access Key Secret");
}
//进行自动创建OSS测试
String bucketName = Global.get("ALIYUN_OSS_BUCKETNAME");
if(bucketName == null){
return error("数据表system中没有ALIYUN_OSS_BUCKETNAME,数据表有缺,初始化OSS失败!");
}else{
if(bucketName.equals("auto")){
//若是为auto,则是第一次刚开始用,自动创建
bucketName = "wangmarket"+DateUtil.timeForUnix10();
}
}
OSSUtil.accessKeyId = id;
OSSUtil.accessKeySecret = secret;
OSSUtil.bucketName = bucketName;
OSSUtil.endpoint = ConfigManagerUtil.getSingleton("xnx3Config.xml").getValue("aliyunOSS.endpoint");
OSSUtil.refreshUrl();
try {
//判断这个bucketName是否存在
boolean have = OSSUtil.getOSSClient().doesBucketExist(bucketName);
if(!have){
//如果不存在这个bucketName,则自动创建一个
CreateBucketRequest createBucketRequest= new CreateBucketRequest(bucketName);
createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead); // 设置bucket权限为公共读,默认是私有读写
OSSUtil.getOSSClient().createBucket(createBucketRequest);
System.out.println("自动创建buckname: "+bucketName);
}else{
System.out.println("OSS未自动创建!因为检测到BucketName已存在!若不是您手动创建的,则建议您按照以下两点进行操作,然后再来创建。");
System.out.println("1.将/src/xnx3Config.xml文件中,aliyunOSS节点下的bucketName设置为空,即将其中配置的数据删除掉");
System.out.println("2.将数据表system中,name为ALIYUN_OSS_BUCKETNAME的这一列,将其值改为auto");
return error("OSS未自动创建!因为检测到BucketName已存在!若不是您手动创建的,则建议您按照以下两点进行操作,然后再来创建。");
}
} catch (Exception e) {
return error("操作失败!错误代码:"+e.getMessage().toString());
}
//将其存入system数据表
sqlService.executeSql("update system set value = '"+id+"' WHERE name = 'ALIYUN_ACCESSKEYID'");
sqlService.executeSql("update system set value = '"+secret+"' WHERE name = 'ALIYUN_ACCESSKEYSECRET'");
sqlService.executeSql("update system set value = '"+bucketName+"' WHERE name = 'ALIYUN_OSS_BUCKETNAME'");
//设置为禁止安装
sqlService.executeSql("update system set value = 'false' WHERE name = 'IW_AUTO_INSTALL_USE'");
//更新缓存
systemService.refreshSystemCache();
return success();
}
开发者ID:xnx3,项目名称:wangmarket,代码行数:69,代码来源:InstallController_.java
示例9: accessPrivate
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
public ObjectOperation accessPrivate(){
access(CannedAccessControlList.Private);
return this;
}
开发者ID:wayshall,项目名称:onetwo,代码行数:5,代码来源:OssClientWrapper.java
示例10: accessPublicRead
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
public ObjectOperation accessPublicRead(){
access(CannedAccessControlList.PublicRead);
return this;
}
开发者ID:wayshall,项目名称:onetwo,代码行数:5,代码来源:OssClientWrapper.java
示例11: setBucketAcl
import com.aliyun.oss.model.CannedAccessControlList; //导入依赖的package包/类
/**
* Bucket权限控制.
* <p>
* public-read-write:
* 任何人(包括匿名访问)都可以对该bucket中的object进行上传、下载和删除操作;所有这些操作产生的费用由该bucket的创建者承担
* ,请慎用该权限。<br>
* public-read: 只有该bucket的创建者可以对该bucket内的Object进行写操作(包括上传和删除);任何人(包括匿名访问)
* 可以对该bucket中的object进行读操作。<br>
* private: 只有该bucket的创建者才可以访问此Bukcet。其他人禁止对此Bucket做任何操作。<br>
*
* @param client client
* @param bucketName bucketName
* @param acl CannedAccessControlList是枚举类型,包含三个值: Private 、 PublicRead 、 PublicReadWrite ,它们分别对应相关权限
*/
public static void setBucketAcl(OSSClient client, String bucketName, CannedAccessControlList acl) {
client.setBucketAcl(bucketName, acl);
}
开发者ID:funtl,项目名称:framework,代码行数:18,代码来源:BucketService.java
注:本文中的com.aliyun.oss.model.CannedAccessControlList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论