Skip to content
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.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
npm install
npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build'
- name: Setup Pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v5
deploy:
environment:
name: github-pages
Expand All @@ -49,4 +49,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
rm -f .gitignore

- name: Archive Add-on
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: cloud_files
path: cloud_files
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.2'
extensions: dom, curl, sqlite, libxml, mbstring, zip, pcntl, pdo, mysql, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
ini-values: error_log=/home/runner/php_errors.log, memory_limit=128M
Expand All @@ -52,7 +52,7 @@ jobs:
working-directory: ee/build-tools
run: |
content=`node -pe 'JSON.parse(process.argv[1]).tag' "$(cat build.json)"`
echo "::set-output name=BUILD_VERSION::$content"
echo "BUILD_VERSION=$content" >> $GITHUB_OUTPUT

- name: Run build process
working-directory: ee/build-tools
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2]
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
os: [ubuntu-latest]

name: Cypress Tests, PHP${{ matrix.php }} - ${{ matrix.os }}
Expand Down Expand Up @@ -175,13 +175,12 @@ jobs:
run: php tests/serve.php &

- name: Run Cypress Tests
uses: cypress-io/github-action@v3
uses: cypress-io/github-action@v6
with:
spec: cypress/integration/addon_cloud_files/**
browser: chrome
headless: true
working-directory: tests/cypress
config-file: cypress.json
config-file: cypress.config.js
env:
CYPRESS_AWS_S3_KEY: ${{secrets.AWS_S3_KEY}}
CYPRESS_AWS_S3_SECRET: ${{secrets.AWS_S3_SECRET}}
Expand All @@ -196,18 +195,22 @@ jobs:
CYPRESS_CF_R2_SECRET: ${{secrets.CF_R2_SECRET}}
CYPRESS_CF_R2_BUCKET: ${{secrets.CF_R2_BUCKET}}
CYPRESS_CF_R2_URL: ${{secrets.CF_R2_URL}}
CYPRESS_BB_B2_KEY: ${{secrets.BB_B2_KEY}}
CYPRESS_BB_B2_SECRET: ${{secrets.BB_B2_SECRET}}
CYPRESS_BB_B2_REGION: ${{secrets.BB_B2_REGION}}
CYPRESS_BB_B2_BUCKET: ${{secrets.BB_B2_BUCKET}}
CYPRESS_CF_TEST_FOLDER: ${{ matrix.php }}_${{ github.sha }}
CYPRESS_KEEP_DEBUG: ${{vars.KEEP_DEBUG != 'false'}}

- name: Archive screenshots
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: vars.KEEP_DEBUG != 'false' && failure()
with:
name: cypress-tests-PHP${{ matrix.php }}
path: tests/cypress/cypress/screenshots/

- name: Archive server errors
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: vars.KEEP_DEBUG != 'false' && failure()
with:
name: error.PHP${{ matrix.php }}.log
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
/vendor/
/vendor-bin/*/vendor
/vendor-bin/*/vendor
node_modules/
119 changes: 119 additions & 0 deletions Adapter/BackblazeB2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?php

namespace CloudFiles\Adapter;

use ExpressionEngine\Dependency\Aws\S3\S3Client;
use ExpressionEngine\Dependency\League\Flysystem;
use ExpressionEngine\Library\Filesystem\Adapter\AdapterInterface;
use ExpressionEngine\Library\Filesystem\Adapter\AdapterTrait;
use ExpressionEngine\Service\Validation\ValidationAware;

class BackblazeB2 extends Flysystem\AwsS3v3\AwsS3Adapter implements AdapterInterface, ValidationAware
{
use AdapterTrait;

protected $_validation_rules = [
'key' => 'required',
'secret' => 'required',
'region' => 'required',
'bucket' => 'required',
];

public function __construct($settings = [])
{
$this->settings = $settings;
$client = new S3Client([
'credentials' => [
'key' => $settings['key'],
'secret' => $settings['secret']
],
'region' => $settings['region'] ?: 'east-001',
'version' => 'latest',
'endpoint' => "https://s3.{$settings['region']}.backblazeb2.com",
'exception_class' => \ExpressionEngine\Dependency\Aws\S3\Exception\S3Exception::class
]);

parent::__construct($client, $settings['bucket']);
}

public static function getSettingsForm($settings)
{
return [
[
'title' => 'Application Key ID',
'desc' => 'Enter your Backblaze B2 Key ID',
'fields' => [
'adapter_settings[key]' => [
'type' => 'text',
'value' => $settings['key'] ?? '',
'required' => true
]
]
],
[
'title' => 'Application Key',
'desc' => 'Enter your Backblaze B2 Key',
'fields' => [
'adapter_settings[secret]' => [
'type' => 'text',
'value' => $settings['secret'] ?? '',
'required' => true
]
]
],
[
'title' => 'Region',
'desc' => 'Enter the region for your Backblaze B2 Bucket',
'fields' => [
'adapter_settings[region]' => [
'type' => 'text',
'value' => $settings['region'] ?? '',
'required' => true
]
]
],
[
'title' => 'Bucket Name',
'desc' => 'Enter the name of your Backblaze B2 Bucket',
'fields' => [
'adapter_settings[bucket]' => [
'type' => 'text',
'value' => $settings['bucket'] ?? '',
'required' => true
]
]
],
[
'title' => 'Path',
'desc' => 'Enter the path inside your Backblaze B2 Bucket',
'fields' => [
'server_path' => [
'type' => 'text',
'value' => $settings['server_path'] ?? '',
'required' => false
]
]
],
[
'title' => 'Url',
'desc' => 'Enter the url used to access your Backblaze B2 Bucket',
'fields' => [
'url' => [
'type' => 'text',
'value' => $settings['url'] ?? '',
'required' => false
]
]
]
];
}

public function getBaseUrl()
{
return implode('/', array_filter([
'https://s3.'.$this->settings['region'].'.backblazeb2.com',
$this->getBucket(),
$this->getPathPrefix()
]));
}
}
12 changes: 12 additions & 0 deletions Adapter/CloudflareR2.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,16 @@ public function getBaseUrl()
$this->getPathPrefix()
]));
}

/**
* Get the object acl presented as a visibility.
*
* @param string $path
*
* @return string
*/
protected function getRawVisibility($path)
{
return Flysystem\AdapterInterface::VISIBILITY_PRIVATE;
}
}
2 changes: 1 addition & 1 deletion Adapter/DigitalOcean.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct($settings = [])
'key' => $settings['key'],
'secret' => $settings['secret']
],
'region' => $settings['region'],
'region' => $settings['region'] ?: 'nyc1',
'version' => 'latest',
'endpoint' => "https://{$settings['region']}.digitaloceanspaces.com",
'exception_class' => \ExpressionEngine\Dependency\Aws\S3\Exception\S3Exception::class
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## [Unreleased]

### Added

- Filesystem Adapter for integrating with Backblaze B2 service
- Support for PHP 8.4

### Fixed

- An issue with Cloudflare R2 where moving a file into a different subfolder would fail

## [1.1.0] - 2023-07-28

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cloud Files

For installation and usage please [read the documentation](docs/index.md)
For installation and usage please [read the documentation](docs/docs/index.md)

## Contributing

Expand Down
7 changes: 6 additions & 1 deletion addon.setup.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
// Cloud Files works with all PHP versions supported by ExpressionEngine 7
// However the S3 SDK is now showing warnings when used with older PHP versions
// https://aws.amazon.com/blogs/developer/announcing-the-end-of-support-for-php-runtimes-8-0-x-and-below-in-the-aws-sdk-for-php/
$_ENV['AWS_SUPPRESS_PHP_DEPRECATION_WARNING'] = $_ENV['AWS_SUPPRESS_PHP_DEPRECATION_WARNING'] ?? true;

require __DIR__ . '/vendor-build/autoload.php';

Expand All @@ -12,7 +16,8 @@
'settings_exist' => false,
'filesystem_adapters' => [
\CloudFiles\Adapter\AwsS3::class,
\CloudFiles\Adapter\DigitalOcean::class,
\CloudFiles\Adapter\BackblazeB2::class,
\CloudFiles\Adapter\CloudflareR2::class,
\CloudFiles\Adapter\DigitalOcean::class,
]
);
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"require": {
"php": "^7.2 || ^8.0",
"bamarni/composer-bin-plugin": "^1.5",
"expressionengine/flysystem": "1.x-dev",
"aws/aws-sdk-php": "3.337.x",
"league/flysystem": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0"
},
Expand All @@ -23,19 +25,32 @@
"bamarni/composer-bin-plugin": true
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ExpressionEngine/flysystem"
}
],
"scripts": {
"post-install-cmd": [
"@composer bin all install --ansi",
"Aws\\Script\\Composer\\Composer::removeUnusedServices",
"@prefix-dependencies"
],
"post-update-cmd": [
"@composer bin all update --ansi",
"Aws\\Script\\Composer\\Composer::removeUnusedServices",
"@prefix-dependencies"
],
"prefix-dependencies": [
"vendor/bin/php-scoper add-prefix --output-dir=./vendor-build --force --quiet",
"COMPOSER_VENDOR_DIR=vendor-build composer dump-autoload",
"php scoper.fix.php"
]
},
"extra": {
"aws/aws-sdk-php": [
"S3"
]
}
}
Loading
Loading