Skip to content

Releases: TCB13/thunder-tus-php

Fix Singles

11 Nov 11:43
Compare
Choose a tag to compare
  • Fix the upload-offset header when a single part upload returns checksum mismatch.

Express TUS - Fast Singles

25 Oct 11:12
Compare
Choose a tag to compare
  • Express extension now features faster single part uploads by not creating containers / temporary part uploads;
  • Other small performance and error handling improvements.

Bezos Time!

24 Oct 16:17
Compare
Choose a tag to compare
  • Implemented S3 backend storage.
  • Fixed issues in temporary container removal for some backend storages.
$server  = new \ThunderTUS\Server($request, $response);

$client = new S3Client([
    "version"     => "latest",
    "region"      => "...",
    "endpoint"    => "...",
    "credentials" => [
        "key"    => "--key--",
        "secret" => "--secret---",
    ],
]);
$backend  = new S3($client, "your-bucket", "optional-path-prefix");
$server->setStorageBackend($backend);

$server->setUploadMaxFileSize(50000);
$server->setApiPath("/tus");
$server->handle();

Finish them all!

23 Oct 11:36
Compare
Choose a tag to compare
  • Implemented completeAndFetch(), completeAndStream() and complete()
  • MongoDB Backend: increased download buffer size to 10M;
  • Better method documentation.

This release breaks previous code using the fetchFromStorage() method. This functionality is now avilable via the newcompleteAndFetch() method.

You can also now retrive the finished upload as a stream by calling completeAndStream() or keep it in the same storage as the temporary parts with complete().

2.0.3: Monkeys are great at storage and do dependency injection

23 Sep 11:17
Compare
Choose a tag to compare
  • Implemented the MongoDB / GridFS storage backend;
  • Refactor of the StorageInterface;
  • Multiple improvements related to dependency injection.

MongoDB Storage Backend

// Connect to your MongDB
$con = new \MongoDB\Client($configs->uri, $configs->options]);
$mongodb= $con->selectDatabase($configs->db]);

// Start ThunderTUS
$server  = new \ThunderTUS\Server($request, $response);

// Load the MongoDB backend
$mongoBackend = new MongoDB($mongodb);
$server->setStorageBackend($mongoBackend );

// Set other settings and process requests
$server->setUploadMaxFileSize(50000);
$server->setApiPath("/tus");
$server->handle();

// Send the response back to the client
$response = $server->getResponse();

Process / Fetch Finished Uploads

Since StorageInterface was refactored every storage backend must now implement public function fetchFromStorage(string $name, string $destinationDirectory): bool.

This method is used to fetch a finished upload from the backend storage. It abstracts backend storage file retrivel in a way that the programmer doen't need to know what backend storage is being used at all times. This is useful when the TUS Server is provided by some kind of Service Provider in a dependency injection scenarios. Here's an example of how to retrieve an uploaded file:

$finalStorageDirectory = "/var/www/html/uploads";
$server = new Server();
$status = $server->fetchFromStorage($filename, $finalStorageDirectory);
if (!$status) {
      throw new \Exception("Could not fetch ({$filename}) from storage backend: not found.");
}

The file will be deleted from the storage backend and stored in $finalStorageDirectory directory.

ThunderTUS & Dependency Injection

This release also make it easier to use thunder-tus-php in dependency injection scenarios. You can now delay providing the http request and response implementations until later. This allows you, for instance, to instantiate the Server in a Service Provider and use it in a controller.

Here is an example of a ThunderTUS service provider:

public static function register()
{
    $settings = $this->container->get("settings.tusProtocol");

    // Create the server
    $server = new Server(); // No request or response implementations passed here

    // Load the filesystem Backend
    $backend = new FileSystem($settings->path]);
    $server->setStorageBackend($backend);

    // Set TUS upload parameters
    $server->setUploadMaxFileSize((int)$settings->maxSize]);
    $server->setApiPath($settings->endpoint]);
    
    return $server;
}

Now in your controller responsible for handling uploads you might do something like:

public function upload()
{
    // Resolve TUS using the container
    /** @var \ThunderTUS\Server $server */
    $server = $this->container->get(\ThunderTUS\Server::class);

    // Load the request or response implementations here!
    $server->loadHTTPInterfaces($this->request, $this->response); 

    // Handle the upload request
    $server->handle();

    // Send the response back to the client
    return $server->getResponse();
}

2.0.2: You may redis!

17 Sep 09:32
Compare
Choose a tag to compare
  • Experimental redis-based storage backend

Example of use:

$server  = new \ThunderTUS\Server($request, $response);

$redisBackend = new Redis($redisClient);
$server->setStorageBackend($redisBackend);

$server->setUploadMaxFileSize(50000);
$server->setApiPath("/tus");
$server->handle();

Your file will be uploaded into redis. You may retrieve it later manually to a local folder or by calling: \ThunderTUS\Store\Redis::downloadIntoLocalFolder($redisClient, "/uploads/tus/", $filename)

Update: please read https://github.com/TCB13/thunder-tus-php/releases/tag/2.0.3 on how to fetch finished downloads from the storage.

2.0.1: Enable PHP 7.2

11 Sep 12:44
Compare
Choose a tag to compare
  • Enable PHP 7.2

2.0: Abstract backend storage

11 Sep 11:29
Compare
Choose a tag to compare

thunder-tus-php now supports multiple storage backends via the StoreInterface interface. The FileSystem backend is now available in order to provide filesystem-based storage as before.
Please read the changes at examples/client.php for more info.

1.0.4: LICENSE

13 Feb 10:16
a6a8782
Compare
Choose a tag to compare
  • Added LICENSE

1.0.3: Standards

27 Dec 12:50
Compare
Choose a tag to compare
  • Strict PSR7;
  • Faster input stream.