通过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 中的错误,还是我用错了 gaufrette?我听说它可能试图在 gaufrette 中使用二进制模式而不是 ascii 模式,但我不知道如何更改这一点

通过将我的适配器从mode FTP_ASCII(默认)更改为FTP_BINARY它就像一个魅力。

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