Skip to content

Commit

Permalink
add bucket setter and getter
Browse files Browse the repository at this point in the history
  • Loading branch information
albertcht committed Oct 26, 2017
1 parent 10ed658 commit 4be2dff
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/S3Presigned.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getSimpleUploadUrl($key, $minutes = 10, array $options = [], $gu
// http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#putobject
// http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
$defaults = [
'Bucket' => $this->bucket,
'Bucket' => $this->getBucket(),
'Key' => $this->getPrefix() . $key,
'ACL' => 'public-read'
];
Expand All @@ -52,7 +52,7 @@ public function getUploadForm($key, $minutes = 10, array $policies = [], array $
$defaults = $defaults ? array_merge($overrides, $defaults) : $overrides;
$defaultPolicies = [
['acl' => 'public-read'],
['bucket' => $this->bucket],
['bucket' => $this->getBucket()],
['starts-with', '$key', $this->getPrefix()]
];
$policies = $policies ? array_merge($defaultPolicies, $defaults) : $defaultPolicies;
Expand All @@ -70,7 +70,7 @@ public function listObjects()
// http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#listobjects
// https://github.com/thephpleague/flysystem-aws-s3-v3/blob/master/src/AwsS3Adapter.php
$resultPaginator = $this->client->getPaginator('ListObjects', [
'Bucket' => $this->bucket,
'Bucket' => $this->getBucket(),
'Prefix' => $this->getPrefix()
]);

Expand All @@ -91,7 +91,7 @@ public function listObjects()
public function deleteObject($key)
{
return $this->client->deleteObject([
'Bucket' => $this->bucket,
'Bucket' => $this->getBucket(),
'Key' => $key
]);
}
Expand All @@ -109,8 +109,8 @@ private function normalizeObject(array $object)
private function getPostObject(array $defaults, array $options, $minutes = 10)
{
return new PostObjectV4(
$this->client,
env('AWS_S3_BUCKET'),
$this->getClient(),
$this->getBucket(),
$defaults,
$options,
"+{$minutes} minutes"
Expand Down Expand Up @@ -146,7 +146,7 @@ public function getPrefixedUri()
return $this->getBaseUri() . $this->getPrefix();
}

public function setPrefix($prefix = '')
public function setPrefix($prefix)
{
$this->prefix = $prefix;

Expand All @@ -158,6 +158,18 @@ public function getPrefix()
return $this->prefix;
}

public function setBucket($bucket)
{
$this->bucket = $bucket;

return $this;
}

public function getBucket()
{
return $this->bucket;
}

public function getClient()
{
return $this->client;
Expand Down

0 comments on commit 4be2dff

Please sign in to comment.