问题描述
我正在尝试使用 Laravel 8 中的 Dropbox 驱动程序将一个(DomPDF 生成的)PDF 文件上传到 Dropbox。我已经安装了 spatie/flysystem-dropbox 并创建了一个包含以下内容的 DropboxServiceProvider.php:
<?php
namespace App\Providers;
use Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client;
use Spatie\FlysystemDropbox\DropboxAdapter;
class DropboxServiceProvider extends ServiceProvider
{
public function boot()
{
Storage::extend('dropbox',function ($app,$config) {
$client = new Client([$config['key'],$config['secret']]);
return new Filesystem(new DropboxAdapter($client));
});
}
public function register()
{
//
}
}
服务提供者也添加到我的配置/应用提供者中:
'providers' => [
...
App\Providers\DropboxServiceProvider::class,...
]
在我的配置/文件系统中,我添加了 dropbox 驱动程序(dropbox 应用程序密钥和机密也在 .env 文件中设置):
'dropbox' => [
'driver' => 'dropbox','key' => env('DROPBOX_APP_KEY'),'secret' => env('DROPBOX_APP_SECRET'),]
现在,当我尝试运行以下代码时,它返回 false 并且该文件没有出现在我的 Dropbox 中。当我将磁盘更改为“本地”时,文件会上传到我的本地存储。
$path = "pdf/file.pdf";
$storage_path = Storage::path($path);
$contents = file_get_contents($storage_path);
$upload = Storage::disk('dropbox')->put($path,$contents);
return $upload;
我已经尝试通过运行 php artisan config:clear
来清除我的配置。在尝试了许多不同的事情之后,我不知道我做错了什么,所以任何建议将不胜感激!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)