通过 FTP 的 Gaufrette 无法正常工作

Gaufrette via FTP does not work correctly

我正在使用 Gaufrette 通过 FTP 获取 PDF 文件

knp_gaufrette:
  adapters:
    invoice_ftp:
      ftp:
        host: ftp.localhost
        port: 21
  filesystems:
    invoice:
      adapter: invoice_ftp

我正在使用

下载文件
$url = sprintf('upload/%s/%s.%s', $this->getFolderName($file), $file, $extension);
$file = $this->filesystem->get($url);
$content = $file->getContent();
file_put_contents($newfile, $content);

但这让我在 PDF 文件中出错

但如果我使用

$url = sprintf('ftp://ftp.localhost/upload/%s/%s', $this->getFolderName($filename), $filename . '.PDF');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
file_put_contents($newfile, $content);

这是gaufrette的bug,还是我gaufrette用错了? 我听说它可能试图在 gaufrette 中使用二进制模式而不是 ascii 模式,但我不知道如何更改它

通过将我的适配器从 mode FTP_ASCII(默认)更改为 FTP_BINARY,它非常有效。

knp_gaufrette:
  adapters:
    invoice_ftp:
      ftp:
        host: ftp.localhost
        port: 21
        mode: FTP_BINARY