Search by

webwizardsusa / laravel-tus

webwizardsusa

Resumable TUS uploads for Laravel: chunked uploads that survive dropped connections and page reloads, Claimed into any disk, with a Blade component and an optional Filament field.

Package info

github.com/webwizardsusa/laravel-tus

pkg:composer/webwizardsusa/laravel-tus

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-12-04 15:00 UTC

This package is auto-updated.

Last update: 2026-12-04 15:01:04 UTC


README

Under active development. This package is still changing and may not be ready for production use yet. Until 1.0, a minor release can include breaking changes, so check the changelog before you upgrade.

Resumable uploads for Laravel over the TUS protocol. Files are sent in chunks, so they can be larger than PHP's upload limits, and an interrupted upload resumes where it stopped, even after a page reload. A finished Upload waits until your code Claims it, which moves the file to any disk (S3 included). Use it from a plain Blade form, or with Filament through the optional TusUpload form field.

Requires PHP 8.3+ and Laravel 12 or 13 (Filament 5 for the optional field).

composer require webwizardsusa/laravel-tus
php artisan vendor:publish --tag=tus-config
php artisan vendor:publish --tag=tus-migrations
php artisan vendor:publish --tag=tus-assets   # the browser script, for the Blade component
php artisan migrate

Upload Profiles

Every Upload is sent under an Upload Profile: named limits defined in code, usually in a service provider's boot().

use Webwizardsusa\Tus\Facades\Tus;

Tus::profile('videos')
    ->maxSize('4G')            // checked before any bytes are sent
    ->mimes(['video/*'])       // sniffed from the finished file, never taken from the browser
    ->ttl(60 * 24);            // minutes an idle Upload lives (default: config('tus.ttl'))

Tus::profile('avatars')->maxSize('5M')->mimes(['image/jpeg', 'image/png'])->allowGuests();

Uploads belong to the signed-in user, or to the session for guests. Guests may upload only to profiles that call allowGuests(). Nobody else can resume, inspect or cancel an Upload.

In a Blade form

<form method="POST" action="{{ route('videos.store') }}">
    @csrf
    <x-tus::upload profile="videos" name="video" accept="video/*" />
    <button>Save</button>
</form>

Files upload as soon as they're chosen, and the form won't submit until they finish. A finished Upload adds a hidden input holding its ID (name="video", or name="video[]" with multiple). Validate the ID, then Claim it:

use Webwizardsusa\Tus\Facades\Tus;
use Webwizardsusa\Tus\Rules\CompleteUpload;

$request->validate(['video' => ['required', new CompleteUpload('videos')]]);

$path = Tus::claim($request->input('video'))->store('videos', 's3');
// or ->storeAs('videos', 'intro.mp4', ['disk' => 's3', 'visibility' => 'public'])

CompleteUpload checks that the Upload exists, belongs to the current user or session, is under the given profile, and is Complete. Claiming moves the file and deletes the Upload.

In Filament

use Webwizardsusa\Tus\Filament\Forms\Components\TusUpload;

TusUpload::make('video')
    ->profile('videos')
    ->disk('s3')
    ->directory('videos')
    ->visibility('public');

TusUpload::make('attachments')->profile('documents')->multiple()->reorderable();

TusUpload::make('photos')->profile('photos')->multiple()->reorderable()->filepond();

By default the field shows a plain list of files. ->filepond() uses FilePond instead, in Filament's FileUpload wrapper so it looks like FileUpload, with image previews, drag-and-drop reordering, and the profile's size and type limits checked before a file is sent. Files still go through TUS. FileUpload's image editor and cropping aren't included.

The field saves what FileUpload saves (a path, or a list of paths with multiple()), so it can take over an existing column. Saving the form validates each new Upload and Claims it. Removing a stored file from the field doesn't delete it from the disk. Run php artisan filament:assets after installing or updating.

Pruning

Uploads that Expire, whether unfinished, finished but never Claimed, or Rejected, are deleted with their files by tus:prune. With --orphans it also deletes staging files that no Upload owns, such as files left behind when rows were deleted outside the package, once they're older than tus.ttl. Schedule it:

Schedule::command('tus:prune --orphans')->hourly();

Add --pretend to list what would be deleted without deleting anything.

Things to know

  • Chunks are assembled on the local disk (tus.staging) and moved on Claim, because object stores can't append. With several web servers, staging must be shared storage.
  • Keep tus.chunk_size (5 MB by default) under your web server's request body limit.
  • The routes are /tus/{profile} and /tus/{profile}/{upload}, in the web middleware group by default.
  • Supported TUS extensions: creation, termination, expiration and checksum (sha1).
  • When a finished file's content type isn't accepted, the Upload is Rejected: its bytes are deleted and the browser is told why.

Testing

composer test

License

MIT. See LICENSE.md.