lara8818's avatar

[L5] Accessing the Public Link of an Upload

Hey guys, here is my dilemma: I'm using Laravel 5 on Heroku for a client project and have to support file uploading. For those that don't know, Heroku is a read-only file system so simply storing files locally is not an option. I have an S3 account set up and can successfully upload and store files from my application using $filesystem->put().

My problem arises when I need to get the public link for an uploaded file. If I had direct access to the FlySystem instance that Laravel is using, then I could use the following method to get at the S3 object and ultimately retrieve the public link.

$url = $flysystem->getAdapter()->getClient()->getObjectUrl($bucket, $filename);

Sifting through the source code for Laravel's file system (namely the FilesystemAdapter class) does not currently offer any kind of accessor to get to the Flysystem $driver instance.

Is there a better way to get the URL for the uploaded file? I'd really rather not have to build my own contract and service provider for this if it could be avoided.

0 likes
3 replies
lara9765's avatar

Did you find a suitable solution for this? I'm currently running into the same issue and haven't been able to locate a workable solution - any pointers?

lara9765's avatar

I ended up with the same thing, was just hopeful - maybe when L5 is released to the world there will be a better alternative - Thanks for the follow up though!

Please or to participate in this conversation.