superius/filepond

Laravel 后端模块,用于文件pond上传

v2.0.1 2024-08-27 09:51 UTC

This package is auto-updated.

Last update: 2024-09-27 10:06:11 UTC


README

Laravel 文件Pond 后端

FilePond 提供一个集成式 Laravel 后端

我们目前支持 `process` 和 `revert` 方法,并使用 Laravel 加密/解密方法来确保这些操作的安全性。

:rocket: 2分钟内快速启动

Laravel 配置

在您的 Laravel 项目的 composer.json 文件中添加此包。

composer require superius/filepond

如果您需要编辑配置,可以使用以下命令发布它:

php artisan vendor:publish --provider="Superius\Filepond\FilepondServiceProvider"
// Get the temporary path using the serverId returned by the upload function in `FilepondController.php`
$filepond = app(\Superius\Filepond\Filepond::class);
$disk = config('filepond.temporary_files_disk');

$path = $filepond->getPathFromServerId($serverId);
$fullpath = Storage::disk($disk)->get($filePath);


// Move the file from the temporary path to the final location
$finalLocation = public_path('output.jpg');
\File::move($fullpath, $finalLocation);

外部存储

您可以使用任何 Laravel 磁盘 作为临时文件的存储。如果您为临时文件和最终位置使用不同的磁盘,则需要将文件从临时位置复制到新磁盘,然后自己删除临时文件。

如果您使用默认的 local 磁盘,请确保您的项目中存在 /storage/app/filepond 目录,并且可写。

Filepond 客户端配置

这是安装 filepond 后需要设置的 Filepond JS 配置的最小版本。

FilePond.setOptions({
  server: {
    url: '/filepond/api',
    process: '/process',
    revert: '/process',
    patch: "?patch=",
    headers: {
      'X-CSRF-TOKEN': '{{ csrf_token() }}'
    }
  }
});