-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
patch an issue with AWS S3 SDK #3701
Conversation
patch an issue with AWS S3 SDK SDK crashes without this patch and we can't use our S3-like buckets
This is our stack trace : We use Cellar from Clever Cloud with "league/flysystem-aws-s3-v3": "^1.0" dependency Without this patch, we got "something went wrong" on our flarum's home page when we updated from 1.1 to 1.5 or 1.6 |
Hello @sebartyr, Can you clarify how you instantiate the s3 adapter inside Flarum? I'm especially interested in the config params as the FilesystemAdapter seems to apply some of these values while generating the URL. Thanks. |
Sorry for my late answer. Actually, i'm not working on it at the moment. I will let you know when i will be on it again |
We use this class : <?php
namespace CleverCloud\Flarum;
use Flarum\Filesystem\DriverInterface;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\Foundation\Config;
use Illuminate\Contracts\Filesystem\Cloud;
use League\Flysystem\Filesystem;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter as S3Adapter;
use Illuminate\Filesystem\FilesystemAdapter;
class CellarFilesystemDriver implements DriverInterface
{
public function build(string $diskName, SettingsRepositoryInterface $settings, Config $config, array $localConfig): Cloud
{
$client = new S3Client($config['cellar']);
$adapter = new S3Adapter($client, $config['buckets'][$diskName]);
$filesystem = new Filesystem($adapter);
return new FilesystemAdapter($filesystem);
}
} and in extend.php : <?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Extend;
return [
(new Extend\Console())->command(\CleverCloud\Flarum\ServeCommand::class),
(new Extend\ServiceProvider())->register(CleverCloud\Flarum\SyslogServiceProvider::class),
(new Extend\Filesystem)->driver('cellar', CleverCloud\Flarum\CellarFilesystemDriver::class),
(new Extend\Console)->command(Blomstra\CacheAssets\Command\CacheAssetsCommand::class),
new Blomstra\Redis\Extend\Redis([
'host' => env('REDIS_HOST', 'localhost'),
'port' => env('REDIS_PORT', 6379),
'password' => env('REDIS_PASSWORD'),
'database' => 0
]),
(new Extend\Validator(Flarum\User\UserValidator::class))->configure(CleverCloud\Flarum\RegistrationValidator::class),
]; |
Still missing the structure of the config you're using to instantiate the cellar driver then I guess? |
'cellar' => [
'endpoint' => 'https://' . env('CELLAR_ADDON_HOST'),
'region' => 'us-east-1',
'use_path_style_endpoint' => true,
'version' => 'latest',
'credentials' => [
'key' => env('CELLAR_ADDON_KEY_ID'),
'secret' => env('CELLAR_ADDON_KEY_SECRET'),
],
],
'buckets' => [
'flarum-assets' => env('ASSETS_BUCKET'),
'flarum-avatars' => env('AVATARS_BUCKET'),
'flarum-uploads' => env('UPLOADS_BUCKET'),
] This ? @luceos |
patch an issue with AWS S3 SDK in src/Api/Serializer/ForumSerializer.php
SDK crashes without this patch and we can't use our S3-like buckets