Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Add support for non-seekable streams #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/FileDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ public function sendDownload ($filename, $forceDownload = true)
header("Content-Transfer-Encoding: binary");
header("Content-Length: {$this->getFileSize()}");

@ob_clean();

rewind($this->filePointer);
@ob_end_clean();

$meta = stream_get_meta_data($this->filePointer);

if( $meta['seekable'] == true )
rewind($this->filePointer);

fpassthru($this->filePointer);
}

Expand Down Expand Up @@ -159,4 +163,4 @@ public static function createFromString ($content)

return new FileDownload($file);
}
}
}