Skip to content

Commit c9664dd

Browse files
committed
修复hyperf 2.2版本中filesystem不存在put方法的bug
1 parent d888339 commit c9664dd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Controller/Upload.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Hyperf\HttpServer\Contract\RequestInterface;
2121
use Hyperf\HttpServer\Contract\ResponseInterface;
2222
use Psr\Container\ContainerInterface;
23+
use Hyperf\Filesystem\Version;
2324

2425
/**
2526
* @ApiController(prefix="/upload",tag="上传")
@@ -102,7 +103,11 @@ protected function saveFiles(UploadedFileAlias $file, $fileName = 'image')
102103
{
103104
$file_name = config('admin.upload.save_path', '/upload');
104105
$file_name = $file_name . '/' . $fileName . '/' . date('Ym') . '/' . date('d') . '/' . uuid(16) . '.' . strtolower($file->getExtension());
105-
Storage()->getDriver()->put($file_name, $file->getStream()->getContents());
106+
if(Version::isV2()){
107+
Storage()->getDriver()->write($file_name, $file->getStream()->getContents());
108+
}else{
109+
Storage()->getDriver()->put($file_name, $file->getStream()->getContents());
110+
}
106111
return [
107112
'path' => $file_name,
108113
'name' => $file->getClientFilename(),

0 commit comments

Comments
 (0)