iperamuna/filament-chunk-upload 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

iperamuna/filament-chunk-upload

最新稳定版本:1.0.0

Composer 安装命令:

composer require iperamuna/filament-chunk-upload

包简介

Chunked File Upload implementation for Filament 5 Forms

README 文档

README

Latest Version on Packagist Total Downloads License

Filament Chunk Upload

A Filament form component that enables chunked file uploads using FilePond, powered by rahulhaque/laravel-filepond. This package is designed to handle large file uploads reliably by splitting them into smaller chunks.

Requirements

  • PHP 8.2+
  • Laravel 10+
  • Filament 3+ (v5 supported)
  • rahulhaque/laravel-filepond package installed and configured

Installation

You can install the package via composer:

composer require iperamuna/filament-chunk-upload

Ensure you have configured rahulhaque/laravel-filepond according to its documentation.

1. Publish Configuration and Migrations

After installing the package, publish the configuration and migration files:

php artisan vendor:publish --provider="RahulHaque\Filepond\FilepondServiceProvider"

2. Run Migrations

Run the migrations to create the temporary file storage table:

php artisan migrate

3. Configure FilePond

Update your .env file to configure the disk and URL for FilePond:

FILEPOND_DISK=private
FILEPOND_TEMP_DISK=local
FILEPOND_URL=/filepond

Make sure your config/filesystems.php has a private disk defined if you choose to use it (recommended for secure uploads).

'private' => [
    'driver' => 'local',
    'root' => storage_path('app/private'),
    'visibility' => 'private',
],

Usage

use Iperamuna\FilamentChunkUpload\ChunkedFileUpload in your Filament resources or forms:

use Iperamuna\FilamentChunkUpload\ChunkedFileUpload;

ChunkedFileUpload::make('attachment')
    ->label('Upload File')
    ->chunkSize(10485760) // Optional: Set chunk size in bytes (default 10MB)
    ->directory('uploads')
    ->visibility('private')
    ->required();

Features

  • Chunked Uploads: Automatically splits large files into chunks based on chunkSize.
  • Secure Dehydration: Handles the secure transfer of temporary files to their final destination upon form submission.
  • Filament Integration: inherites standard Filament validation and storage configuration (disk, directory, visibility).

Serving Large Files (Secure Download)

Since this package is designed for large files often stored on a private disk, you should use a streamed download response to avoid memory exhaustion (OOM) errors in PHP.

Add a route to your routes/web.php to handle secure, signed downloads:

use Illuminate\Support\Facades\Storage;

Route::get('/attachments/{attachment}/download', function (App\Models\Attachment $attachment) {
    // 1. Verify Signed URL for security
    if (! request()->hasValidSignature()) {
        abort(403);
    }

    $diskName = config('filament.default_disk', 'private');
    
    // 2. Stream the file to the client
    // We use streamDownload with manual buffer clearing to prevent memory issues with large files
    return response()->streamDownload(function () use ($diskName, $attachment) {
        $stream = Storage::disk($diskName)->readStream($attachment->file_path);

        // Clear output buffer to prevent OOM
        if (ob_get_level()) {
            ob_end_clean();
        }

        fpassthru($stream);

        if (is_resource($stream)) {
            fclose($stream);
        }
    }, $attachment->file_name);
})->name('attachments.download');

You can then generate a download link in your Filament resource or Blade view:

use Illuminate\Support\Facades\URL;

URL::signedRoute('attachments.download', ['attachment' => $record->id]);

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固