MihailDev / yii2-elfinder

Yii2 ElFinder
Other
170 stars 76 forks source link

S3 file path error after uploading #137

Open eugene-chernyshenko opened 4 years ago

eugene-chernyshenko commented 4 years ago

I get invalid path to file uploading file to s3

Steps to reproduce:

  1. Press "add link"
  2. Upload file
  3. Choose file

You will get a link like "/elfinder/connect?path=&_csrf=0OgzayMV76bwOyMdP1pBN6nkEa-FGrPo6iAZh7lLemjimF0obkCV4KhPbmxyFght3oZk7bVK0YOoZUHP1xRPWA%3D%3D&cmd=file&target=fls1_enhjLnR4dA"

But if you do these steps without uploading you will get expected link

eugene-chernyshenko commented 4 years ago
Screen Shot 2020-05-01 at 04 05 40
eugene-chernyshenko commented 4 years ago
Screen Shot 2020-05-01 at 04 06 04
MihailDev commented 4 years ago

please show you config file (dont forgot hide credencials)

eugene-chernyshenko commented 4 years ago
'controllerMap' => [
        'elfinder' => [
            'class' => 'mihaildev\elfinder\PathController',
            'access' => ['@'],
            'root' => [
                'class' => 'mihaildev\elfinder\flysystem\Volume',
                'url' => 'https://' . getenv('S3_BUCKET') .'.ams3.digitaloceanspaces.com/files',
                'component' => [
                    'class' => 'creocoder\flysystem\AwsS3Filesystem',
                    'key' => getenv('S3_ACCESS_KEY'),
                    'secret' => getenv('S3_ACCESS_SECRET'),
                    'bucket' => getenv('S3_BUCKET'),
                    'region' => getenv('S3_REGION'),
                    // 'version' => 'latest',
                    // 'baseUrl' => 'your-base-url',
                    'prefix' => 'files',
                    'options' => [
                        "ACL" => "public-read",
                    ],
                    'endpoint' => getenv('S3_ENDPOINT'),
                ],
            ],
        ],
    ],
eugene-chernyshenko commented 4 years ago
"require": {
        "php": ">=7.0",
        ...
        "mihaildev/yii2-elfinder": "*",
        "mihaildev/yii2-ckeditor": "*",
        "creocoder/yii2-flysystem": "0.9.4 as 0.8.1",
        "mihaildev/yii2-elfinder-flysystem": "*"
    },
eugene-chernyshenko commented 4 years ago

I had to hack a yii2-flysystem version using alias cause there is no way to set s3 endpoint in 0.8.1 version but 0.9.4 brokes dependencies

eugene-chernyshenko commented 4 years ago

@MihailDev any ideas?

MihailDev commented 4 years ago

fix version https://github.com/MihailDev/yii2-elfinder-flysystem/commit/74227f5725ba7ceb5f8f46944a45ce156516c94e

i dont test all drivers but I think you need to configure the baseUrl parameter for the component

sorry for the long answer i have health problems. If you solve the problem, write how you will do it. Thanks in advance.