Sunday, February 1, 2015

Command line tools for object storage such as S3cmd and awscli provide almost all the functionality required to interact with objects and storage. However, the use of SDK enables integration with different types of user interfaces: For example, if we want to get ACLs, we use :
  public function get($bucket, $key = null, $accessKey=null, $accessSecret=null){
             if ($bucket == null) return array('Grants' => array());
            $client = $this->getInstance($accessKey, $accessSecret);
            if ($key != null){
             $acls = $client->getObjectAcl(array(
                  'Bucket' => $bucket,
                  'Key' => $key));
             if ($acls == null) $acls = array('Grants' => array());
             return $acls;
            }
            else {
             $acls = $client->getBucketAcl(array(
                  'Bucket' => $bucket));
             if ($acls == null) $acls = array('Grants' => array());
             return $acls;
            }
  }
If we want to set the ACLs we could use:
 // 'private', 'public-read', 'project-private', 'public-read-write', 'authenticated-read', 'bucket-owner-read', 'bucket-owner-full-control'
  public function set($bucket, $key, $acl, $accessKey=null, $accessSecret=null){
    $client = $this->getInstance($accessKey, $accessSecret);
    $result = $client->putObjectAcl(array(
    'ACL'    => $acl,
    'Bucket' => $bucket,
    'Key'    => $key,
    'Body'   => '{}'
    ));
    return $result;

  }

#codingexercise
Double GetAlternateEvenNumberRangeSumPower ()(Double [] A, int n, int m)
{
if (A == null) return 0;
Return A.AlternateEvenNumberRange
SumPower(n,m);
}

No comments:

Post a Comment