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 Adapter fails when "/" is requested #41509

Closed
mabdullahsari opened this issue Mar 16, 2022 · 1 comment
Closed

S3 Adapter fails when "/" is requested #41509

mabdullahsari opened this issue Mar 16, 2022 · 1 comment

Comments

@mabdullahsari
Copy link
Contributor

mabdullahsari commented Mar 16, 2022

  • Laravel Version: 9.5.1
  • PHP Version: 8.1.3
  • Database Driver & Version: MySQL 8.0.28

Description:

AwsS3V3Adapter's url method returns an AWS validation error when / is issued as command, because League's PathPrefixer strips it away and ends up with an empty string. GetObject's Key arg requires a string with a length of at least 1, hence the error:

InvalidArgumentException with message 'Found 1 error while validating the input provided for the GetObject operation: [Key] expected string length to be >= 1, but found string length of 0'

Setting the root to / does fix it, but breaks a bunch of other URLs (in my case).

Steps To Reproduce:

Storage::disk('s3')->url('/')

Environment is untouched:

's3' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'url' => env('AWS_URL'),
    'endpoint' => env('AWS_ENDPOINT'),
    'root' => env('AWS_ROOT', ''),
],

I was going to submit a PR to fix this, but I'm not sure if the problem is due to Laravel's adapter or League's prefixer.

Thanks 🙏

@mabdullahsari
Copy link
Contributor Author

Seems like it's a bug in Spatie's Medialibrary package.

For anyone coming across the same issue: spatie/laravel-medialibrary#2778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant