zoukankan      html  css  js  c++  java
  • ECS

    .Net

    Java-Maven配置

    //ECS SDK Java maven
    <dependency>    
        <groupId>com.emc.ecs</groupId>    
        <artifactId>object-client</artifactId>    
        <version>3.1.3</version>   
    </dependency>
    //Gateway SDK Java maven
    <dependency>     
        <groupId>com.emphant.gateway</groupId>     
        <artifactId>ecs-gateway-client</artifactId>    
        <version>1.0.3</version> 
    </dependency>
    //AWS S3 SDK Java Maven(AWS S3 SDK,功能上兼容ECS)
    <dependency>       
        <groupId>com.amazonaws</groupId>       
        <artifactId>aws-java-sdk-s3</artifactId>       
        <version>1.9.1</version>     
    </dependency>
    

    详情参见:Java-EcsDemo
    若存在日志slf4j-log4j12冲突的问题,解决如下:

    日志冲突问题解决:
    <dependency>
       <groupId>com.emc.ecs</groupId> 
       <artifactId>object-client</artifactId> 
       <version>3.1.3</version>
       <exclusions>
         <exclusion>
            <artifactId>slf4j-log4j12</artifactId>
            <groupId>org.slf4j</groupId>
         </exclusion>
       </exclusions>
    </dependency>
    

    提供一个ECS的java工具类

    
    

    Java

    生命周期

    配置过期策略,支持增删改查,注意,若当前Bucket策略空,直接删除会报错。.Net版本
    查询

    private LifecycleConfiguration GetEcsRules() {
        // Retrieve current configuration
        GetLifecycleConfigurationRequest getRequest  = new GetLifecycleConfigurationRequest {
                BucketName = _bucketName  };
        var response = _s3Client.GetLifecycleConfiguration(getRequest);
        return (response != null && response.Configuration != null) ? response.Configuration : null;
    }
    

    删除

    private void DeleteEcsRules() {
        // Delete current configuration
        DeleteLifecycleConfigurationRequest deleteRequest  = new DeleteLifecycleConfigurationRequest {
                BucketName = _bucketName  };
        _s3Client.DeleteLifecycleConfiguration(deleteRequest);
    }
    

    更新

    private void UpdateEcsRules(LifecycleConfiguration lcConfig_New = null) {
        LifecycleRuleExpiration lcRuleExpiration =  new LifecycleRuleExpiration() {
                Days = _expireDay, };
    
        LifecycleRule lcRule_1 = new LifecycleRule() {
            Expiration = lcRuleExpiration,
            Prefix = DateTime.Now.AddDays(-2).ToString(_prefix_format),
            Status = LifecycleRuleStatus.Enabled,
        };
    
        LifecycleConfiguration lcConfig = new LifecycleConfiguration();
        lcConfig.Rules.Add(lcRule_1);
    
        PutLifecycleConfigurationRequest request  = new PutLifecycleConfigurationRequest() {
                BucketName = _bucketName,  Configuration = lcConfig,
        };
        _s3Client.PutLifecycleConfiguration(request);
    }
    

    具体参见:PutLifecycleConfigurationRequest Class

  • 相关阅读:
    微信卡券领用中的问题
    abp的开发20180425
    typescript 接口的新认识
    Jquery构建Form表单Post提交数据的简单方法
    EF使用时异常:对一个或多个实体的验证失败。有关详细信息
    VS快捷键简单记录
    比较和排序 IComparable And IComparer
    wpf全局异常
    MailBee的简单使用
    json数据的获取(网络摘抄)
  • 原文地址:https://www.cnblogs.com/wjcx-sqh/p/11694707.html
Copyright © 2011-2022 走看看