Coder Social home page Coder Social logo

spazzmarticus / tusserver Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 1.0 208 KB

php tus.io - Server for resumable file uploads using PSR HTTP standards.

License: GNU General Public License v3.0

PHP 98.27% HTML 1.73%
tus tus-protocol php resumable-upload

tusserver's Introduction

Tus - Server

A server implementation of the "tus.io Resumable File Uploads" protocol using PSR HTTP standards.

Installation

Use composer to install:

composer require spazzmarticus/tus-server

Don't forget to install a PSR-7 and PSR-17 implementation you want to use.

Implements

Uses

Demo

You can demo TusServer by installing the dev-dependencies ( composer install ) and running the provided server.php :

php -S localhost:8000 example/server.php

Open your browser, surf to localhost:8000/ and use (Uppy) to upload.

Uploads are stored at example/uploads/... , the filesystem cache is at example/cache/ .

Surf to localhost:8000/reset to permanently delete uploads, intermediate chunks and the metadata-storage. There might be an error log at example/log/php-error.php and a server log at example/log/tus-server.log containing some additional information.

Test

Automated testing is done with:

  • PHPUnit - unit- and integration-tests
  • newman - Verify TusServer meets the tus. io-protocol.

Examples

  • Slim v4 - Slim routes allow to directly call this tus-server implementation.

๐Ÿ‘‹ This is how I use tus-server.

Cache as storage?!

TusServer needs something fast to store metadata about uploads. Since the payload is small and performance is important, caches can be used.

Instead of using a volatile cache only, you should use a chain containing both a fast volatile and a slower non-volatile cache. (Losing the metadata mid-upload does not allow for resuming uploads. )

๐Ÿ‘‹ I use symfony/cache:

 $volatileCache = new Symfony\Component\Cache\Adapter\ApcuAdapter('...');
 $nonVolatileCache = new Symfony\Component\Cache\Adapter\FilesystemAdapter('', 0, __DIR__ . '/...');

 $cacheChain = new Symfony\Component\Cache\Adapter\ChainAdapter([$volatileCache, $nonVolatileCache]);

 $storage = new Symfony\Component\Cache\Psr16Cache($cacheChain);

Alternatives

  • ankitpokhrel/tus-php - Did not provide enough flexibility for my needs and is the reason I decided to start my own implementation. (Provides a php tus-client, if you are looking for that.)

tusserver's People

Contributors

darthf1 avatar dependabot[bot] avatar spazzmarticus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

darthf1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.