Laravel Storage: Download get content always returns false

154 Views Asked by At

I am downloading a file from an FTP storage. Even though the file exists and has content, the $download->getContent() always returns false.

I want that method because I need to use it for put to save the file in another storage.

Is this a known laravel issue?

Note: I have run it from phpunit and laravel commands and both return false.

$ftpStorage = Storage::disk('ftp');

dump($ftpStorage->fileExists('OIP.jpeg')); //true
$download = $ftpStorage->download('OIP.jpeg');
dump($download->getContent()); //false

dump of $download:

Symfony\Component\HttpFoundation\StreamedResponse^ {#732 // app/Console/Commands/MakePics.php:45
  +headers: Symfony\Component\HttpFoundation\ResponseHeaderBag^ {#731
    #headers: array:5 [
      "content-type" => array:1 [
        0 => "image/jpeg"
      ]
      "content-length" => array:1 [
        0 => "13480"
      ]
      "content-disposition" => array:1 [
        0 => "attachment; filename=OIP.jpeg"
      ]
      "cache-control" => array:1 [
        0 => "no-cache, private"
      ]
      "date" => array:1 [
        0 => "Tue, 07 Mar 2023 19:40:39 GMT"
      ]
    ]
    #cacheControl: []
    #computedCacheControl: array:2 [
      "no-cache" => true
      "private" => true
    ]
    #cookies: []
    #headerNames: array:5 [
      "content-type" => "Content-Type"
      "content-length" => "Content-Length"
      "content-disposition" => "Content-Disposition"
      "cache-control" => "Cache-Control"
      "date" => "Date"
    ]
  }
  #content: null
  #version: "1.0"
  #statusCode: 200
  #statusText: "OK"
  #charset: null
  #callback: Closure()^ {#733
    class: "Illuminate\Filesystem\FilesystemAdapter"
    this: Illuminate\Filesystem\FilesystemAdapter {#712 …}
    use: {
      $path: "OIP.jpeg"
    }
  }
  #streamed: false
  -headersSent: false
}
0

There are 0 best solutions below