Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mindexperiment's avatar

storage url from s3

Hi, I'm reading an uploaded file from S3 bucket, but the storage facade returns an apigateway path:

Storage::disk('s3')->url( $video->path )
// -> apigateway.eu-central-1.amazonaws.com/my_bucket/originals/RNDdNU7lbgBG2rdFCOjEsFvuc5WufOuhx7U6JNBm.qt

how can I use this path to see the video?

0 likes
6 replies
Mindexperiment's avatar

Hi, thank you

I'm using laravel 5.7, in my env file I have set these variables:

AWS_ACCESS_KEY_ID=my-id
AWS_SECRET_ACCESS_KEY=my-key
AWS_DEFAULT_REGION=eu-central-1
AWS_BUCKET=test
AWS_URL=apigateway.eu-central-1.amazonaws.com

here is the only place where I see "apigateway..."

[edit]

I found that:

class Video {
 //..

 public function getStorageUrl() {
  $s3 = Storage::disk('s3')->getAdapter()->getClient();
  return $s3->getObjectUrl( env('AWS_BUCKET'), $this->path );
 }
}

returns the correct object url of the file but the folder on S3 must be public.

jaythanki's avatar

@mindexperiment while storing an file had you put 'public' $store = Storage::disk('s3')->put(FILE_PATH, FILE_CONTENT, 'public');

Mindexperiment's avatar

@jaythanki I store the uploaded files with

$path = $request->file('uservideo')->store($custompath, 's3');

maintaining the s3 folder private is another requirement of the project, any advice appreciated

Please or to participate in this conversation.