UTF-8 on FTP adapter
chrisooo3 opened this issue · 7 comments
chrisooo3 commented
Bug Report
Problem with encoding utf-8 on FTP adtaper
How to reproduce
- 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
- 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
@bytehead Thanks ;) when will you merge it? When it will be available on packagist
to download it to my project?
bytehead commented
There you go: https://packagist.org/packages/oneup/flysystem-bundle#3.7.1
Thanks for reporting!
chrisooo3 commented
@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
Weird. Can you describe your setup a bit more? How do you use the upload?
chrisooo3 commented
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