Skip to content

Root folder is not created when missing (sftp) #1832

@ionutantohi

Description

@ionutantohi

Bug Report

Q A
Flysystem Version 3.29.1
Adapter Name SftpAdapter
Adapter version 3.29.0

Summary

Root folder is not created when is missing and UnableToWriteFile exception is thrown

Note: It is created though if the path contains a prefix.

How to reproduce

use League\Flysystem\Config;
use League\Flysystem\PhpseclibV3\SftpAdapter;
use League\Flysystem\PhpseclibV3\SftpConnectionProvider;

$provider = SftpConnectionProvider::fromArray([
    'driver' => 'sftp',
    'host' => 'domain',
    'username' => 'username',
    'password' => 'password',
]);


$adapter = new SftpAdapter(
    connectionProvider: $provider,
    root: 'uploads'
);

// Make sure that "uploads" folder is missing on remote server before each test

// ❌ Case 1: UnableToWriteFile exception is thrown
// I expect to work and file to be uploaded at /uploads/file.txt
$adapter->write('file.txt', 'content', new Config());


// ✅ Case 2: File is uploaded at /uploads/parent_folder/file.txt even if the "uploads" folder doesn't exist
$adapter->write('parent_folder/file.txt', 'content', new Config());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions