I am using the Storage provider to upload files to rackspace like so...
$logo = $request->file('logo');
$content = fopen($logo->getRealPath(), 'r+');
\Storage::disk('cdn')->put('logo.png', $content);
Now, how can I get the url of the file above? I has been looking for a method in the API and it seems so impossible.
The issue here is the way the FlySystem adapter works.
For most operations it will just return a boolean indicating if an operation was successful or not. Even Laravel's FlySystem wrapper also doesn't keep track of paths, so a workaround would be to build the path yourself after a successful upload.
By using the filesystem configuration, we can come up with something like this:
$cdn_url = config('filesystems.disks.cdn.container').'/logo.png';
You get the picture.
I usually store the disk public URL in the config/filesystems.php file. For example:
Then in my model, I define a mutator for the field containing the file name:
This allows me: