Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.
/ flysystem-hash Public archive

Flysystem plugin for generating a hash value of a given file

License

Notifications You must be signed in to change notification settings

emgag/flysystem-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flysystem Plugin for generating hash value of file

build Software License Packagist Version

NOTE: Plugins were removed in Flysystem 2.0 and thus this library is only available for Flysystem 1.x.

A plugin for the Flysystem file system abstraction library to generate hash values of a file. See hash_algos() function for supported hash algorithms.

Tested with Local and WebDav adapters, but as the hash is built directly from the stream resource it should work for all other adapters as well.

Installation

composer require emgag/flysystem-hash

Usage

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');

License

flysystem-hash is licensed under the MIT License.