valentinloiseau/laravel-resumable-upload
Composer 安装命令:
composer require valentinloiseau/laravel-resumable-upload
包简介
Easy and flexible integration of resumable (chunk and async) uploading of files for any JS file uploader such as Resumable.js
README 文档
README
This laravel Package implements a chunk uploading feature using upload handlers. The idea is, that you have one single Upload route and you pass the handler name to init the Upload to it. This handler then handles the authorization, and file processing. The Upload itself is managed by the Upload Controller globally.
Installation
The installation is done via composer
composer require chrisidakwo/laravel-resumable-upload
As the package comes with some migrations, run them.
artisan migrate
The package comes with a config, so you should publish the package using
artisan vendor:publish
Installation
In the resumable-upload.php config file, you need to declare Handlers to use this package.
A handler always needs to extend the ChrisIdakwo\ResumableUpload\Contracts\UploadHandler Contract.
The methods to implement are pretty straight forward.
Config
- Handler
- Database Table Name
- Route
Javascript
A simple implementation of Resumable.js
Requirements: axios,resumable.js
It's important to set the forceChunkSize parameter because each chunk is checked to have the exact Chunk size (except if it's the last one).
If not, the chunk is marked as invalid and refused.
Also, the chunkSize must be the same as defined in the laravel config (resumable-upload.php)
const r = new Resumable({
target:'/upload',
query: file => {
if(file.token){
return {token:file.token};
}
return {};
},
chunkSize: (10 * 1024 * 1024),
forceChunkSize: true
});
Once a file is added, you need to call the init method with a handler name to get an upload token, which is then used to perform the upload itself.
r.on('fileAdded', file => {
// Pause the file
file.pause();
// Make the init call
axios.post('/upload/init',{
handler:'basic', // name defined in config
size: file.size,
type: file.file.type,
name: file.fileName
}).then(response => {
if(response.data.data.token){
// Save the token to the file
file.token = response.data.data.token;
file.pause(false);
r.upload();
}
else{
file.cancel();
}
}).catch(error => {
file.cancel();
});
});
As soon as the upload is done, we will call the complete endpoint to process the file
r.on('fileSuccess', file => {
axios.post('/upload/complete',{
token: file.token
}).then(response => {
console.log(response.data);
})
})
Done, you can now upload large files in chunks and process them easily.
valentinloiseau/laravel-resumable-upload 适用场景与选型建议
valentinloiseau/laravel-resumable-upload 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 valentinloiseau/laravel-resumable-upload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 valentinloiseau/laravel-resumable-upload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-06