1

Any ideas on what is going wrong here? I'm totally stumped.

Code

I'm running the following code on a local development server (MacOS with Laravel Valet):

$file = $request->file('uploaded_file');
$folder = '001-testing';
$filename = '12345.'.$file->extension();
$s3_path = $file->storeAs($folder, $filename, 's3');

Result

504 Gateway Time-out

Not a very useful error!

.env

AWS_ACCESS_KEY_ID=*****
AWS_SECRET_ACCESS_KEY=*****
AWS_DEFAULT_REGION=us-west-2
AWS_BUCKET=*****
AWS_ENDPOINT=https://s3.us-west-2.amazonaws.com
AWS_URL=https://s3.us-west-2.amazonaws.com

I'm not sure about ENDPOINT and URL - do I have these right? These are new variables from previous Laravel versions.

composer.json

 "require": {
        "php": "^7.2.5",
        "aws/aws-sdk-php": "^3.147",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.0",
        "laravel/tinker": "^2.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "league/flysystem-cached-adapter": "^1.1"
Holly
  • 3,601
  • 1
  • 17
  • 23

1 Answers1

0

By default you cannot access S3 buckets with the http protocol, if http is a requirement configure your bucket as a website endpoint and allow public access.

How to S3 bucket for static webhosting

If http/https isn't a requirement, switch your AWS_ENDPOINT & AWS_URL variables over to s3:// protocol and direct them to your specific bucket

Ryan Sayer
  • 86
  • 8
  • Thank you for your answer! Http is not a requirement; I just didn't know what to enter for AWS_ENDPOINT & AWS_URL. So should it be s3://s3.us-west-2.amazonaws.com or s3://us-west-2.amazonaws.com? – Holly Aug 13 '20 at 01:42