Commit d87ecb2f authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

when filesize cannot be read (why ?)

parent 04b4fafb
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -31,12 +31,16 @@ class ImageUtils
        return new Filesystem($adapter);
    }

    public static function downloadImage(Filesystem $fs, string $path, string $name){
    public static function downloadImage(Filesystem $fs, string $path, string $name) : void{
        $mimetype = 'application/octet-stream';
        $filesize = $fs->fileSize($path);
        $encodedFilename = urlencode($name);
        header("Content-Type: {$mimetype}");
        try {
            $filesize = $fs->fileSize($path);
            header("Content-Length: {$filesize}");
        }catch(Exception $e) {
            error_log($e->getMessage());
        }
        header('Accept-Ranges: none');
        header('Content-Disposition: inline' . ";filename=\"{$encodedFilename}\";filename*=UTF-8''{$encodedFilename}");
        header('Cache-Control: private'); // Workarounds for IE weirdness