barryvdh / elfinder-flysystem-driver

elFinder driver for Flysystem
183 stars 41 forks source link

S3 URL incorrect on upload when URL is specified #89

Open nbolender opened 1 year ago

nbolender commented 1 year ago

This was a tough one to find.

Setup:

    'disks' => [
        's3' => [
            'URL' => env('AWS_URL'),
            'alias' => 'Uploads',
        ],
    ],
  1. Upload a file, example.jpg to the S3 disk
  2. Observe that the URL returned from the connector is https://bucket.s3.amazonaws.com/xample.com instead of https://bucket.s3.amazonaws.com/example.com

Working configuration:

    'disks' => [
        's3' => [
            'alias' => 'Uploads',
        ],
    ],
  1. Upload a file, example.jpg to the S3 disk
  2. Observe that the URL returned from the connector is correctly https://bucket.s3.amazonaws.com/example.com

This seems to occur because when the URL option is not present, a URLCallback is set to get the URL from flysystem. If it is present, that URLCallback is not set, so it falls back to calling elFinderVolumeDriver::getContentUrl, which strips the first character from the filename before forming the base URL.

bckr75 commented 1 year ago

Uploads via SFTP are affected with the same problem.