w360 / import-gpg-excel
用于上传多尺寸图片的库
3.0.7
2023-05-23 03:30 UTC
Requires
- ext-json: *
- maatwebsite/excel: ^3.1
Requires (Dev)
- laravel/legacy-factories: ^1.3
- orchestra/testbench: ^7.24
README
用于导入以pgp格式加密的文件的库
目录
安装
> composer require w360/import-gpg-excel
可发布
php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=migration
迁移
> php artisan migrate
配置
通过更新应用程序的 .env 文件中的 QUEUE_CONNECTION 变量来指导应用程序使用数据库驱动程序
QUEUE_CONNECTION=database
GPG_SECRET_PASSPHRASE=mysecretpassphrase
最后,通过更新 .env 文件中的 GPG_PRIVATE_KEY 变量或修改应用程序配置文件夹中找到的 gnupg.php 文件来指导应用程序 GPG 私钥的路径
#.env
GPG_PRIVATE_KEY=/home/user/.gnupg/private.asc
或者
#/config/gnupg.php
/*
|--------------------------------------------------------------------------
| GPG Signing Key
|--------------------------------------------------------------------------
|
| extension to save the decry
|
*/
'private_key' => env('GPG_PRIVATE_KEY', __DIR__.'/key.asc')
示例
用于加载使用 OpenPGP 加密的 Excel 文件的示例
####App\Imports\UsersImport.php
<?php namespace App\Imports; use Illuminate\Support\Collection;use Illuminate\Support\Facades\Hash; use Maatwebsite\Excel\Concerns\ToModel; use App\Models\User; use W360\ImportGpgExcel\Imports\GpgImport; class UsersImport extends GpgImport { /** * if the object is returned, the row is considered * to have been imported successfully, * otherwise the row will be marked as failed in the report * * @param array | Collection $row * @return mixed * @throws Exception */ public function row($row) { $findUser = User::where('identifier', $row['identifier'])->first(); if(!$findUser){ return User::create([ 'name' => $row['name'], 'email' => $row['email'], 'password' => Hash::make($row['password']), ]); } return $this->exception('User '.$row['identifier'].' already exists'); } }
####App\App\Http\Controllers\TestController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use W360\ImportGpgExcel\Facades\ImportGPG; use W360\ImportGpgExcel\Models\Import; use App\Imports\UsersImport; class TestController extends Controller { /** * allows you to upload a file and associate * it with an import file that will be * executed asynchronously via cron jobs * * @param Request $request */ private function upload(Request $request){ if($request->hasFile('file')){ ImportGPG::create($request->file, 'default', UsersImport::class); } } /** * show the detail of all imported files * * @return \Illuminate\Database\Eloquent\Collection */ public function showImportFiles(){ return Import::all(); } /** * show current import file details * * @return mixed */ public function showCurrentImport(){ return Import::where('model_type', UsersImport::class) ->where('state', 'processing') ->first(); } }
特性
- 允许上传使用 OpenPGP 加密的 Excel 文件
库
- Laravel Excel https://docs.laravel-excel.com/
许可证
MIT 许可证 (MIT)
版权所有 © 2023 W360 S.A.S
特此授予任何人免费获得本软件及其相关文档文件(以下简称“软件”)的副本的权利,用于不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许向软件提供副本的个人这样做,前提是遵守以下条件
上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论此类责任是基于合同、侵权或其他原因,无论此类责任是否因软件或其使用或其他方式产生。