And yeah; im using Heroku
Problem with getting Amazon S3 download path
Hello everyone, hope everyone is doing great.
So I guess the title of my subject resumes the problem :P.
I have a bucket in Amazon S3, it's operationnal now, I try to upload files, that's perfect !.
Now I want to retieve the uploaded file and download it, easy right ? :/.
I actually retrieve the file(cuz the name of the file is stored in the DB).
So I found the file using :
$myFile = Storage::disk("filesystems.default")->get($fileName);
public function download($file){ $headers = [ 'Content-Type' => $contentType, 'Content-Description' => 'File Transfer', 'Content-Disposition' => "attachment; filename={$file}", 'filename'=> $file ]; return response()->download(Storage::disk("filesystems.default")->get($file), $file); }
And my function
download($file) is called in a blade like {{url('/download/'. $myItem->filleName) }}
But the link generated isn't the link of my amazon S3 source, but the link of the app.
So I tried another way :
$s3=Storage::disk("s3"); $s3->getDriver()->getAdapter()->getClient()->getObjectUrl("mybucketName", $fileName);
This time the url is an amazon link, but kind of inversed :
But actually the link generated in the Amazon Console is like this :
So anyone can help me getting a link to download my files from Amazon S3 bucket please.
thanks (:
You'd just use the storage objects url method
$url = Storage::disk("s3")->url($myItem->filleName);
Please or to participate in this conversation.