1up-lab / OneupFlysystemBundle

A Flysystem integration for your Symfony projects.
MIT License
630 stars 118 forks source link

UTF-8 on FTP adapter #245

Closed chrisooo3 closed 3 years ago

chrisooo3 commented 3 years ago

Bug Report

Problem with encoding utf-8 on FTP adtaper

How to reproduce

1) Set your config to this file:

oneup_flysystem:
    adapters:
        ftp_adapter:
            ftp:
                host: ''
                username: ''
                password: ''
                port: 21
                root: '/'
                passive: true
                ssl: true
                timeout: 30
                utf8: true

2) Go to browser and see error:

Unrecognized option "utf8" under "oneup_flysystem.adapters.ftp_adapter.ftp". Available options are "host", "ignorePassiveAddress", "passive", "password", "permPrivate", "permPublic", "port", "recurseManually", "root", "ssl", "systemType", "timeout", "transferMode", "username".
chrisooo3 commented 3 years ago

@bytehead I am using "oneup/flysystem-bundle": "^3.0"

bytehead commented 3 years ago

Yep, PR is here :)

chrisooo3 commented 3 years ago

@bytehead Thanks ;) when will you merge it? When it will be available on packagist to download it to my project?

bytehead commented 3 years ago

There you go: https://packagist.org/packages/oneup/flysystem-bundle#3.7.1

Thanks for reporting!

chrisooo3 commented 3 years ago

@bytehead After your PR, ftp file upload does not work. The files are empty on the server. When I downgrade to version 3.7.0 everything works fine. May you look at it?

bytehead commented 3 years ago

Weird. Can you describe your setup a bit more? How do you use the upload?

chrisooo3 commented 3 years ago

The code that is responsible for uploading file to FTP server:

...
use League\Flysystem\FilesystemInterface;

final class UploadToFTPHandler implements CommandHandlerInterface
{
    private FilesystemInterface $filesystem;

    public function __construct(FilesystemInterface $ftpFilesystem)
    {
        $this->filesystem = $ftpFilesystem;
    }

    public function __invoke(UploadToFTP $command): void
    {
        $fileContents = 'którzy uczestniczyć w procesie o stary zamek, niegdyś własność';
        $fileContents = mb_convert_encoding($fileContents, 'UTF-8');

        $this->filesystem->write(
            sprintf('%s.txt', uniqid()),
            $fileContents,
            ['mimetype' => 'text/plain; charset=utf-8']
        );
    }
}

Config file:

oneup_flysystem:
    adapters:
        ftp_adapter:
            ftp:
                host: 'test.com'
                username: 'test.com'
                password: 'passwd'
                port: 21
                root: '/'
                passive: true
                ssl: true
                timeout: 30