Example #1
0
 /**
  * getObjectAcl
  *
  * @param string $key
  * @param string $versionId
  *
  * @return \Guzzle\Service\Resource\Model
  */
 public function getObjectAcl($key, $versionId = '')
 {
     $params = ['Bucket' => $this->name, 'Key' => $key];
     if ($versionId) {
         $params['VersionId'] = $versionId;
     }
     return $this->client->getObjectAcl($params);
 }
Example #2
0
 /**
  * Get the visibility of a file
  *
  * @param   string  $path
  * @return  array   file metadata
  */
 public function getVisibility($path)
 {
     $options = $this->getOptions($path);
     $result = $this->client->getObjectAcl($options)->getAll();
     foreach ($result['Grants'] as $grant) {
         if (isset($grant['Grantee']['URI']) && $grant['Grantee']['URI'] === Group::ALL_USERS && $grant['Permission'] === Permission::READ) {
             return array('visibility' => AdapterInterface::VISIBILITY_PUBLIC);
         }
     }
     return array('visibility' => AdapterInterface::VISIBILITY_PRIVATE);
 }
 /**
  * Write a string to a file
  *
  * @param  string  $path     file path
  * @param  string  $content  new file content
  * @return bool
  **/
 protected function _filePutContents($path, $content)
 {
     $oldSettings = $this->getFile($path);
     $settings = array("Bucket" => $this->bucket, "Key" => $this->pathToKey($path), "ACL" => $this->options['acl'], "Body" => $content);
     if ($oldSettings) {
         $settings['Metadata'] = $oldSettings['Metadata'];
         $settings['ContentType'] = $oldSettings['ContentType'];
         $settings['ACP'] = Aws\S3\Model\Acp::fromArray($this->s3->getObjectAcl(array('Bucket' => $this->bucket, 'Key' => $this->pathToKey($path)))->toArray());
         unset($settings['ACL']);
     }
     return $this->s3->putObject($settings);
 }
Example #4
0
 /**
  * @depends testPutAndListObjects
  */
 public function testGetObjectAcl()
 {
     self::log("Getting the object's ACL");
     $model = $this->client->getObjectAcl(array('Bucket' => $this->bucket, 'Key' => self::TEST_KEY));
     $data = array();
     foreach (Acp::fromArray($model->toArray()) as $grant) {
         $grantee = $grant->getGrantee();
         $data[$grantee->getGroupUri()] = array($grantee->getType(), $grant->getPermission());
     }
     $this->assertEquals(2, count($data));
     $this->assertArrayHasKey('http://acs.amazonaws.com/groups/global/AllUsers', $data);
     $this->assertArrayHasKey('http://acs.amazonaws.com/groups/global/AuthenticatedUsers', $data);
     $this->assertEquals(array('Group', 'READ_ACP'), $data['http://acs.amazonaws.com/groups/global/AllUsers']);
     $this->assertEquals(array('Group', 'READ'), $data['http://acs.amazonaws.com/groups/global/AuthenticatedUsers']);
 }
Example #5
0
 /**
  * Returns the access control list (ACL) of an object.
  *
  * @param $bucket
  * @param $key
  *
  * @return mixed
  */
 public function getObjectAcl($bucket, $key)
 {
     $params = ['Bucket' => $bucket, 'Key' => $key];
     return $this->instance->getObjectAcl($params);
 }