When using Laravel’s Storage to check if a file exists on S3, it throws League\Flysystem\UnableToCheckFileExistence with a 403 Forbidden error if the file doesn’t exist.
| |
Why 403 Instead of 404
When an AWS S3 user has s3:GetObject permission but lacks s3:ListBucket, the API returns 403 instead of 404 for non-existent files. This is AWS’s underlying behavior — Flysystem can’t distinguish between “no permission” and “file doesn’t exist.”
See this Laravel issue for related discussion.
Add s3:ListBucket Permission
After adding s3:ListBucket to the IAM Policy, checking for non-existent files will correctly return false.
