n11t/hash-file-service
Composer 安装命令:
composer require n11t/hash-file-service
包简介
Service to persist files based on there hashed content
README 文档
README
HashFileService
Service to persist files based on there hashed content
Sample
Use the service to persist content or files.
Code
<?php
$calculator = new \N11t\HashFileService\HashCalculator\GenericHashCalculator('sha1');
$directory = sys_get_temp_dir() . '/hash-service';
$service = new \N11t\HashFileService\HashFileService($directory, $calculator);
$content = "Hello World\n";
echo $service->persistByContent($content);
echo PHP_EOL;
$file = sys_get_temp_dir() . '/test.txt';
echo $service->persistByFile($file);
echo PHP_EOL;
$handle = fopen($file, 'rb+');
echo $service->persistByResource($handle);
echo PHP_EOL;
Output
/tmp/hash-service/2e/a47907b71df53d55ff2d8e5d6c0da6e6a39c84
/tmp/hash-service/2e/a47907b71df53d55ff2d8e5d6c0da6e6a39c84
/tmp/hash-service/2e/a47907b71df53d55ff2d8e5d6c0da6e6a39c84
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-15