Gaufrette via FTP does not work correctly

1.1k Views Asked by At

Im using Gaufrette to fetch PDF files over FTP

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

And Im downloading the file with

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

But this gives me a error in the PDF file

But if im using

$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);

Is this a bug in gaufrette, or am I using gaufrette wrong? I heard something about its maybe trying to use binary mode in gaufrette instead of ascii mode, but I dont know how to change this

1

There are 1 best solutions below

1
On BEST ANSWER

By changing my adapter from mode FTP_ASCII (default) to FTP_BINARY it worked like a charm.

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