laravel-public-sftp maintained by talvbansal
Public Sftp Adapter for Laravel
An extension to the sftp flysystem adapter that allows you to configure a public URL for files to be accessible from.
# Introduction
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.
# Installation
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:
\TalvBansal\SftpPublic\Providers\SftpPublicServiceProvider::class,
After this a new disk will be automatically registered called public-sftp.
# Configuration
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 SFTP_ROOT folder.
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:
SFTP_ROOT=/var/www/public
SFTP_PUBLIC_ROOT=https://example.com
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.
# Credits
## License
The MIT License (MIT). Please see License File for more information.