An extension to the flysystem Sftp adapter that allows you to configure a public URL for files to be accessible from.
This package is auto-updated.
Last update: 2020-03-19 22:16:01 UTC
An extension to the sftp flysystem adapter that allows you to configure a public URL for files to be accessible from.
The default sftp flysystem adapter does not have a method to get the URL of files on the disk, instead a if you try and call the url() method on the disk instance a
RuntimeException will be thrown.
I wrote this extension to the sftp adapter so that i could upload files using my media-manager package and store the files on a remote server yet still have them in a publicly accessible place.
To get started, install public sftp adapter via the Composer package manager:
composer require talvbansal/laravel-public-sftp
Register the adapter in the
providers array of your
config/app.php configuration file:
After this a new disk will be automatically registered called
Add the relevant configuration from the keys below to access your ssh enabled server:
SFTP_HOST=myserver.com SFTP_USERNAME=username SFTP_PW=password SFTP_PRIVATE_KEY=/optional/path/to/private/key SFTP_ROOT=/path/to/storage/folder SFTP_PUBLIC_ROOT=https://public-url/to-folder-above
The new value to pay attention to here is
SFTP_PUBLIC_ROOT which should be a publicly accessible URL that is serving the contents of the
So if you were using nginx or apache to serve the
/var/www/public folder on a server over https on a domain of
example.com the values would look like this:
You can now use the
public-sftp disk as a filesystem within laravel and will be able to call the
url() method on the disk instance to get a publicly accessible URL of an uploaded file.
The MIT License (MIT). Please see License File for more information.