我们已经将laravel/framework更新为版本^9.0,将联盟/ have系统更新为^3.0。
现在我们有以下错误:Call to undefined method League\Flysystem\Filesystem::put()
我们的代码:Storage::disk('disk-name')->put($concept->id.'.docx', file_get_contents($tmpPath));
在飞行系统升级指南中,他们说:https://flysystem.thephpleague.com/docs/upgrade-from-1.x/
将put()更改为写()方法。
当我查看飞碟系统的来源时,他们使用:
vendor/league/flysystem/src/Filesystem.php
public function write(string $location, string $contents, array $config = []): void
但是当我看到Laravel 9存储立面时,他们仍然使用:
applications/kics/vendor/laravel/framework/src/Illuminate/Support/Facades/Storage.php
put
同样在laravel 9文档中,他们展示了他们建议使用put方法的例子。https://laravel.com/docs/9.x/filesystem#obtaining-disk-instances
有谁知道怎么解决这个问题吗?
谢谢!
`
发布于 2022-09-29 04:48:17
如果使用自定义文件系统磁盘,则需要对自定义服务提供程序进行某些更改。参考文献:https://laravel.com/docs/9.x/upgrade#flysystem-3
年长的
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;
Storage::extend('dropbox', function ($app, $config) {
$client = new DropboxClient(
$config['authorization_token']
);
return new Filesystem(new DropboxAdapter($client));
});
新的
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;
Storage::extend('dropbox', function ($app, $config) {
$adapter = new DropboxAdapter(
new DropboxClient($config['authorization_token'])
);
return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$config
);
});
https://stackoverflow.com/questions/73194777
复制相似问题