Skip to content

Commit 4be2dff

Browse files
committed
add bucket setter and getter
1 parent 10ed658 commit 4be2dff

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

src/S3Presigned.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getSimpleUploadUrl($key, $minutes = 10, array $options = [], $gu
2929
// http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#putobject
3030
// http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html
3131
$defaults = [
32-
'Bucket' => $this->bucket,
32+
'Bucket' => $this->getBucket(),
3333
'Key' => $this->getPrefix() . $key,
3434
'ACL' => 'public-read'
3535
];
@@ -52,7 +52,7 @@ public function getUploadForm($key, $minutes = 10, array $policies = [], array $
5252
$defaults = $defaults ? array_merge($overrides, $defaults) : $overrides;
5353
$defaultPolicies = [
5454
['acl' => 'public-read'],
55-
['bucket' => $this->bucket],
55+
['bucket' => $this->getBucket()],
5656
['starts-with', '$key', $this->getPrefix()]
5757
];
5858
$policies = $policies ? array_merge($defaultPolicies, $defaults) : $defaultPolicies;
@@ -70,7 +70,7 @@ public function listObjects()
7070
// http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-s3-2006-03-01.html#listobjects
7171
// https://github.com/thephpleague/flysystem-aws-s3-v3/blob/master/src/AwsS3Adapter.php
7272
$resultPaginator = $this->client->getPaginator('ListObjects', [
73-
'Bucket' => $this->bucket,
73+
'Bucket' => $this->getBucket(),
7474
'Prefix' => $this->getPrefix()
7575
]);
7676

@@ -91,7 +91,7 @@ public function listObjects()
9191
public function deleteObject($key)
9292
{
9393
return $this->client->deleteObject([
94-
'Bucket' => $this->bucket,
94+
'Bucket' => $this->getBucket(),
9595
'Key' => $key
9696
]);
9797
}
@@ -109,8 +109,8 @@ private function normalizeObject(array $object)
109109
private function getPostObject(array $defaults, array $options, $minutes = 10)
110110
{
111111
return new PostObjectV4(
112-
$this->client,
113-
env('AWS_S3_BUCKET'),
112+
$this->getClient(),
113+
$this->getBucket(),
114114
$defaults,
115115
$options,
116116
"+{$minutes} minutes"
@@ -146,7 +146,7 @@ public function getPrefixedUri()
146146
return $this->getBaseUri() . $this->getPrefix();
147147
}
148148

149-
public function setPrefix($prefix = '')
149+
public function setPrefix($prefix)
150150
{
151151
$this->prefix = $prefix;
152152

@@ -158,6 +158,18 @@ public function getPrefix()
158158
return $this->prefix;
159159
}
160160

161+
public function setBucket($bucket)
162+
{
163+
$this->bucket = $bucket;
164+
165+
return $this;
166+
}
167+
168+
public function getBucket()
169+
{
170+
return $this->bucket;
171+
}
172+
161173
public function getClient()
162174
{
163175
return $this->client;

0 commit comments

Comments
 (0)