Laravel 5 如何使用文件系统选择磁盘
如果我有这样一个控制器:Laravel 5 如何使用文件系统选择磁盘,laravel-5,Laravel 5,如果我有这样一个控制器: class ExampleController extends Controller { protected $filesystem; public function __construct(Filesystem $filesystem) { $this->filesystem = $filesystem; } 如何告诉文件系统我要使用哪个磁盘 i、 e.这不起作用: public function t
class ExampleController extends Controller {
protected $filesystem;
public function __construct(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
}
如何告诉文件系统我要使用哪个磁盘
i、 e.这不起作用:
public function test()
{
$this->filesystem->disk('s3')->doSomething();
}
但这确实:
public function test()
{
\Storage::disk('s3')->doSomething();
}
有没有一种方法可以在不使用Facade的情况下指定要使用的磁盘?好的-我已经解决了
您需要使用工厂合同:
use Illuminate\Contracts\Filesystem\Factory as Filesystem;
这使您可以访问disk()
方法