emgag/flysystem-hash

此包已被废弃,不再维护。未建议替代包。

为指定文件生成哈希值的 Flysystem 插件

v1.0.4 2021-04-03 09:03 UTC

This package is auto-updated.

Last update: 2024-03-28 16:11:27 UTC


README

build Software License Packagist Version

注意:插件已在 Flysystem 2.0 中移除,因此此库仅适用于 Flysystem 1.x。

Flysystem 文件系统抽象库创建文件哈希值的插件。有关支持的哈希算法,请参阅 hash_algos() 函数。

LocalWebDav 适配器进行了测试,但由于哈希值直接从流资源构建,因此也应适用于其他适配器。

安装

composer require emgag/flysystem-hash

使用

use Emgag\Flysystem\Hash\HashPlugin;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem; 

$fs = new Filesystem(new Local(__DIR__));
$fs->addPlugin(new HashPlugin);

// sha256 is default
$sha256 = $fs->hash('file.txt');
$sha256 = $fs->hash('file.txt', 'sha256');
$md5    = $fs->hash('file.txt', 'md5');
$sha1   = $fs->hash('file.txt', 'sha1');

许可

flysystem-hash 采用 MIT 许可证 许可。