Skip to content

ayoob-faraji/php-tus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhpTus

Library for tus server (tus protocol 0.2.1)

Installation

use composer

Client Usage

$client = new PhpTus\Client();
$client->setFilename('/path/of/the/file/to/upload');
$client->setEndPoint('http://example.com/files/');

// Upload 1024 bytes of your file
$client->upload(1024);

// Get the fingerprint to upload the remaining later
$fingerprint = $client->getFingerprint();

// New session
$client = new PhpTus\Client();
$client->setFilename('/path/of/the/file/to/upload');
$client->setEndPoint('http://example.com/files/');
// Indicate the old fingerprint, to resume the upload
$client->setFingerprint($fingerprint);

// Upload the next 2048 bytes of your file 
// (1024 bytes have been sent in the first request)
$client->upload(2048);

// Upload the remaining of your file
$client->upload();

Server Usage

Require : redis-server (on Debian/Ubuntu, apt-get install redis-server)

// Create and configure server
$server = new \PhpTus\Server(__DIR__.'/path-to-save-file', 
                            '/url-to-call/', 
                            array('prefix' => 'php-tus')
);

// Run server
$server->process(true);

If you are with an Apache server, add an .htaccess file to redirect all request in the php page (without that, your PATCH call failed), like :

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

Author

Simon Leblanc contact@leblanc-simon.eu

License

MIT

About

Library for tus server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 99.5%
  • Shell 0.5%