Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
549 views
in Technique[技术] by (71.8m points)

php - Laravel league/flysystem getting file URL with AWS S3

I am trying to build a file management system in Laravel based on league/flysystem: https://github.com/thephpleague/flysystem

I am using the S3 adapter and I have it working to save the uploaded files using:

$filesystem->write('filename.txt', 'contents');

Now I am stuck on generating the download file URL when using the S3 adapter.

The files are saved correctly in the S3 bucket, I have permissions to access them, I just don't know how to get to the S3 getObjectUrl method through the league/flysystem package.

I have tried:

$contents = $filesystem->read('filename.txt');

but that returns the content of the file.

$contents = $filemanager->listContents();

or

$paths = $filemanager->listPaths();

but they give me the relative paths to my files.

What I need is something like "ht...//[s3-region].amazonaws.com/[bucket]/[dir]/[file]..."

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am using Laravel 5.2 and the code below seemed to work fine.

Storage::cloud()->url('filename');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...