-
-
Notifications
You must be signed in to change notification settings - Fork 1
FileSystem_RemoteFile
You may need to assign the namespace to the top of your code
use \Scarlets\Library\FileSystem\RemoteFile;
The filesystem configuration are stored on /config/filesystem.php
.
Then you can pass {the storage name}/your/path
to the LocalFile function.
In the configuration, the driver should be remotefile
and the key
is a secret code that must be similar for the remote server and the current server. The server must have storage
key and the client must have host
key.
For addional security, you may need to define array of allowed ip with allow-ip
key.
It's important to define your secret route for this feature. So you will need this to be set somewhere in the /routes/
.
The example below will occupy the URL of http://server.com/file-handler
for transmission.
RemoteFile::route($url, $storage);
# Example
RemoteFile::route('/file-handler', 'incoming');
Listen for incoming file access.
This can be used for blocking access, renaming file access (using reference parameter), or monitoring.
RemoteFile::listen($storage, $which, $callback);
# Example
RemoteFile::listen('incoming', 'put', function($path, &$value, $isFile){
// ... Record to MySQL maybe?
});
The usage RemoteFile
library is pretty similar with LocalFile library.
For the example:
RemoteFile::put('{remote}/file.txt', 'my value');
$return = RemoteFile::contents('{remote}');
# Output: ['file.txt']