Skip to content

Commit 19b64a7

Browse files
authored
Merge pull request #18 from wilbur-yu/v2
修复hyperf 2.2版本中filesystem不存在put方法的bug
2 parents d888339 + b9c56b2 commit 19b64a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Controller/Upload.php

Lines changed: 3 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,8 @@ 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+
$action = Version::isV2() ? 'write' : 'put';
107+
Storage()->getDriver()->{$action}($file_name, $file->getStream()->getContents());
106108
return [
107109
'path' => $file_name,
108110
'name' => $file->getClientFilename(),

0 commit comments

Comments
 (0)