Skip to content

gg22mm/hyperf-upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hyperf-upload

hyperf-upload 是hyperf框架文件上传包,可本地传,可oss上传,显示,删除。 目前支持阿里oss 与 七牛oss。 也看了这位兄弟的: https://gitee.com/lyxxxh/filestore 用不起来。所以撸了一个。后面可以改成用任务方式异步一下。

基本使用

1、 下载包

composer require wll/hyperf-upload

//如果要用到oss上传可选择安装
composer require qiniu/php-sdk
composer require aliyuncs/oss-sdk-php

2、 发布配置生成文件:config/autoload/filestore.php

bin/hyperf.php vendor:publish hyperf-upload

3、 绑定使用什么上传方式

config/autoload/dependencies.php
修改绑定
'dependencies' => [
	Wll\HyperfUpload\Service\FileStoreInterface::class =>  Wll\HyperfUpload\Service\LocalFileStoreService::class,//默认使用本地上传
	//Wll\HyperfUpload\Service\FileStoreInterface::class => Wll\HyperfUpload\Service\AliyunFileStoreService::class,//阿里oss 
	//Wll\HyperfUpload\Service\FileStoreInterface::class => Wll\HyperfUpload\Service\QiniuFileStoreService::class,//七牛oss 	
],

4、 开始使用

use Hyperf\Utils\ApplicationContext;
use Wll\HyperfUpload\Service\FileStoreInterface;

 public function index(){	
 
   $container = ApplicationContext::getContainer();
   $upload=$container->get(FileStoreInterface::class); //获得上传对象
   
	//返回文件名+扩展名
	$path = $upload->store($request->file('file'));
	
	print_r($path);
	
	//获取可以访问的url
	echo "http的访问url".$upload->url($path);  
	
	
	//删除 
	$a=$upload->delete(['images/43704c244ee5fc5dcb83402f88f33144.jpg']);
	
	if($a){
		echo 'dd';
	}else{
		echo 'ccc';
	}			
   
   	
}

About

hyperf上传包,包括本地与oss

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages