thephpleague / flysystem-sftp

[READ-ONLY SUBSPLIT] Flysystem Adapter for SFTP
309 stars 95 forks source link

Save sftp file to local storage, return false #102

Open raulfdias opened 4 years ago

raulfdias commented 4 years ago

Hello guys! I have a problem regarding trying to save an sftp file to my localstorage. False is returned when I get the file. Follow:

$file = "image.png"; Storage :: disk('sftp')->exists ($file); // retrun true Storage :: disk('sftp')->get($file); // return false

Config: 'sftp' => [ 'driver' => 'sftp', 'host' => 'sftp.lalala.m.br', 'username' => 'src_lt', 'password' => '6324Easdf3wE4',

        // Settings for SSH key based authentication ...
        // 'privateKey' => '/ path / to / privateKey',
        // 'password' => 'encryption-password',

        // Optional SFTP Settings ...
        'port' => 22,
        // 'root' => '/ FOLDER /',
        'timeout' => 1200,

        // 'cache' => [
        // 'store' => 'database',
        // 'exhale' => 600,
        // 'prefix' => 'sftp_cache_',
        //],
    ],
raulfdias commented 4 years ago

By doing everything by hand, you can easily manipulate the file. Now when using the library it doesn't work.

$connection = ssh2_connect('sftp.com.br', 22);
ssh2_auth_password($connection, 'user', 'pass');
$sftp = ssh2_sftp($connection);
$stream = fopen('ssh2.sftp://' . intval($sftp) . '/path/file.csv', 'r');
$content = fread($stream, filesize('ssh2.sftp://' . intval($sftp) . '/path/file.csv'));
fclose($stream);

Storage::disk('local')->put('file.csv', $content);

Is there any parameter that I would need to pass on this connection ??

vladan-me commented 4 years ago

Find the directory where is the file saved and check the permissions and the owner of the file.