Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.75 KB

README.md

File metadata and controls

63 lines (45 loc) · 1.75 KB

fileStreamer

GitHub release License

This library serves a file according to the headers which are sent with a http request. It supports resumable downloads or streaming the content of a file to a client.

If you have any questions, comments or ideas concerning this library, please consult the code documentation at first. Create a new issue if your concerns remain unanswered.

Features

  • Inline disposition.
  • Attachment disposition.
  • Serve a complete file.
  • Serve a single byte range of a file.
  • Serve multiple byte ranges of a file.
  • Set a custom mimetype.

Requirements

  • PHP ^7.4
  • ext-fileinfo *

Installation

The preferred method is to install the library with Composer.

> composer require digilive/file-streamer:^1

Set the version constraint to a value which suits you best.
Alternatively you can download the latest release from GitHub.

Example use

<?php

use DigiLive\FileStreamer\FileStreamer;

// Use composer's auto loader.
$requiredFile = 'Path/To/vendor/autoload.php';

// Or include the library manually.
// $requiredFile = 'Path/To/FileStreamer.php';

require_once $requiredFile;

// Instantiate the library.
$fileStreamer = new FileStreamer('Path/To/File/To/Serve.ext');
// Set inline disposition if wished.
$fileStreamer->setInline();
$fileStreamer->start();
// Execution of PHP will terminate when FileStreamer::start() is finished.