内容纲要

[code]
composer require league/flysystem-dropbox
[/code]

修改 filesystems.php

[code language=”php”]
‘dropbox’ => [
‘driver’ => ‘dropbox’,
‘key’ => ‘your-key’,
‘secret’ => ‘your-secret’
],
[/code]

修改路由
[code language=”php”]
Route::get(‘dropbox-upload-file’, ‘FileController@dropboxFileUpload’);
[/code]

[code language=”php”]
use Dropbox\Client;
use Dropbox\WriteMode;

public function dropboxFileUpload()
{
$Client = new Client(config(‘filesystems.dropbox.key’), config(‘filesystems.dropbox.secret’));
$file = fopen(public_path(‘images/angular_crud.png’), ‘rb’);
$size = filesize(public_path(‘images/angular_crud.png’));
$dropboxFileName = ‘/dropboxfile-name.png’;
$Client->uploadFile($dropboxFileName,WriteMode::add(),$file, $size);
}
[/code]

创建分享链接
[code language=”php”]
$Client->createShareableLink($dropboxFileName);
$Client->createTemporaryDirectLink($dropboxFileName);
[/code]

发表评论

电子邮件地址不会被公开。 必填项已用*标注