Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 Update: Add No Bucket Check #16496

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/lexicon/en/source.inc.php
Expand Up @@ -84,6 +84,7 @@
$_lang['prop_s3.endpoint_desc'] = 'Alternative S3-compatible endpoint URL, e.g., "https://s3.<region>.example.com". Review your S3-compatible provider’s documentation for the endpoint location. Leave empty for Amazon S3';
$_lang['prop_s3.region_desc'] = 'Region of the bucket. Example: us-west-1';
$_lang['prop_s3.prefix_desc'] = 'Optional path/folder prefix';
$_lang['prop_s3.no_check_bucket_desc'] = 'If set, don\'t attempt to check the bucket exists. It can be needed if the access key you are using does not have bucket creation/list permissions.';
$_lang['s3_no_move_folder'] = 'The S3 driver does not support moving of folders at this time.';

/* ftp source type */
Expand Down
11 changes: 10 additions & 1 deletion core/src/Revolution/Sources/modS3MediaSource.php
Expand Up @@ -38,6 +38,7 @@
$bucket = $this->xpdo->getOption('bucket', $properties, '');
$prefix = $this->xpdo->getOption('prefix', $properties, '');
$endpoint = $this->xpdo->getOption('endpoint', $properties, '');
$noBucketCheck = $this->xpdo->getOption('no_check_bucket', $properties, false);

Check warning on line 41 in core/src/Revolution/Sources/modS3MediaSource.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Sources/modS3MediaSource.php#L41

Added line #L41 was not covered by tests

$config = [
'credentials' => [
Expand All @@ -54,7 +55,7 @@

try {
$client = new S3Client($config);
if (!$client->doesBucketExist($bucket)) {
if (!$noBucketCheck && !$client->doesBucketExist($bucket)) {

Check warning on line 58 in core/src/Revolution/Sources/modS3MediaSource.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Sources/modS3MediaSource.php#L58

Added line #L58 was not covered by tests
$this->xpdo->log(
xPDO::LOG_LEVEL_ERROR,
$this->xpdo->lexicon('source_err_init', ['source' => $this->get('name')])
Expand Down Expand Up @@ -158,6 +159,14 @@
'value' => '',
'lexicon' => 'core:source',
],
'no_check_bucket' => [
'name' => 'no_check_bucket',
'desc' => 'prop_s3.no_check_bucket_desc',
'type' => 'combo-boolean',
'options' => '',
'value' => false,
'lexicon' => 'core:source',
],

Check warning on line 169 in core/src/Revolution/Sources/modS3MediaSource.php

View check run for this annotation

Codecov / codecov/patch

core/src/Revolution/Sources/modS3MediaSource.php#L162-L169

Added lines #L162 - L169 were not covered by tests
'imageExtensions' => [
'name' => 'imageExtensions',
'desc' => 'prop_s3.imageExtensions_desc',
Expand Down