geeky / file
使laravel文件上传变得简单 '本地 | 公共 | s3 | ...'
1.0
2018-04-21 16:16 UTC
This package is auto-updated.
Last update: 2024-09-16 03:33:24 UTC
README
本包使文件上传变得非常简单,无论是本地还是云端。只需在配置文件中确定您的磁盘,即可享受上传的乐趣。
要求
为了创建svg或pdf的缩略图,您还应该安装Imagick。
安装
使用composer安装
composer require geeky/file
然后,在config/app.php中,将以下内容添加到服务提供者数组中。
array(
...
Geeky\File\FileServiceProvider::class,
)
最后,在config/app.php中,将以下内容添加到外观数组中。
array(
...
'Gfile' => Geeky\file\FileFacade::class,
)
使用方法
使用外观的示例用法
上传文件.. 如果上传的文件是图像,它将在您想要的路径上传原始图像,并在同一路径创建缩略图目录以自动存储缩略图,您可以从配置文件中确定缩略图的最大宽度和质量。
Gfile::upload($file , 'path/you/want/');
删除文件.. 您可以传递单个文件路径或文件路径数组以删除
Gfile::delete($file_path);
获取文件可见性.. 您可以获取任何文件的可见性.. 可见性应该是公开或私有
Gfile::getVisibility($file_path);
设置文件可见性.. 您可以设置任何文件的可见性.. 可见性应该是公开或私有
Gfile::stVisibility($file_path);
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="Geeky\File\FileServiceProvider" --tag="config"
这是已发布配置文件的内容
<?php
return [
'maxsize' => 500, // Max vert or horiz resolution
'quality' => 90, // Set compression level (1 lowest quality, 100 highest quality)
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| depends on filesystem configuration
|
| Supported Drivers: "local", "ftp", "s3", "rackspace"
|
*/
'disk' => 'local', // supported Drivers: "local", "ftp", "s3", "rackspace"
/*
|--------------------------------------------------------------------------
|
| In Laravel's Flysystem integration, "visibility" is an abstraction of file permissions across
| multiple platforms. Files may either be declared public or private. When a file is declared
| public, you are indicating that the file should generally be accessible to others. For example,
| when using the S3 driver, you may retrieve URLs for public files.
|
*/
'visibility' => 'public' // 'public' , 'private'
];