定制 jmjl161100/laravel-chunk-upload 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

jmjl161100/laravel-chunk-upload

最新稳定版本:v1.0.0

Composer 安装命令:

composer require jmjl161100/laravel-chunk-upload

包简介

Laravel chunk upload support package.

README 文档

README

License PHP Version Laravel Version

Laravel Chunk Upload

Laravel package for handling chunked file uploads with multi-driver support (Local, Qiniu, etc.).

Features

  • ✅ Chunked file upload support
  • ✅ Multiple storage drivers (Local, Qiniu Cloud)
  • ✅ Progress tracking
  • ✅ Automatic chunk merging
  • ✅ Laravel 11.x compatibility

Installation

  1. Install via Composer:
    composer require jmjl161100/laravel-chunk-upload
    

Configuration

Add a new disk to your config/filesystems.php config:

<?php

return [
   'disks' => [
        //...
        'qiniu' => [
           'driver'     => 'qiniu',
           'access_key' => env('QINIU_ACCESS_KEY', 'xxxxxxxxxxxxxxxx'),
           'secret_key' => env('QINIU_SECRET_KEY', 'xxxxxxxxxxxxxxxx'),
           'bucket'     => env('QINIU_BUCKET', 'test'),
           'domain'     => env('QINIU_DOMAIN', 'xxx.clouddn.com'), // or host: https://xxxx.clouddn.com
        ],
        //...
    ]
];

Usage

Basic Upload

use Jmjl161100\ChunkUpload\Facades\CheckUpload;

// initialization
$rt = CheckUpload::init($fileName);

// Upload data in chunks
$rt = CheckUpload::uploadPart($uploadId, $partNumber, $file);

// Complete file upload
$rt = CheckUpload::complete($uploadId, $partList);

Frontend Integration

JavaScript example (using Axios):

async function uploadFile(file) {
    const chunkSize = 5 * 1024 * 1024; // 5MB
    const totalChunks = Math.ceil(file.size / chunkSize);

    for (let i = 0; i < totalChunks; i++) {
        const chunk = file.slice(i * chunkSize, (i + 1) * chunkSize);
        await axios.post('/upload-chunk', {
            file_id: file.name,
            chunk: chunk,
            index: i
        });
    }

    await axios.post('/complete-upload', {file_id: file.name});
}

Drivers

Supported Drivers

  1. Local Driver

    • Chunk Storage: Chunks under the disk root configuration
    • Final Files: Disk root configuration
  2. Qiniu

    • Requires qiniu/php-sdk package
    • Direct upload to Qiniu Cloud Storage

Security

If you discover any security issues, please email author instead of creating an issue.

License

MIT License (see LICENSE)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-18