owow / laravel-drive
此包已被弃用,不再维护。未建议任何替代包。
一个用于Google Drive API的Laravel包
0.1
2016-05-27 10:44 UTC
Requires
- google/apiclient: 2.0.*@rc
This package is not auto-updated.
Last update: 2018-07-29 20:52:50 UTC
README
类开发完成后,README将全部填写。
这是一个Google Drive API的Laravel包装器。尽管它非常基础。
安装
使用composer安装最新版本
composer require owow/laravel-drive
确保你要求自动加载。
配置
在你的终端中运行以下命令以创建一个新的配置文件。
php artisan vendor:publish --provider="OWOW\LaravelDrive\LaravelDriveServiceProvider" --tag="config"
在ROOT/.env文件中,确保你有以下三个变量
GOOGLE_DRIVE_KEY=yourkeyoridfortheservice
GOOGLE_DRIVE_SECRET=yoursecretfortheservice
GOOGLE_DRIVE_REDIRECT_URI=yourredirecturl
用法
即将推出。
示例
文件上传的示例。
/**
* Connenct with Google Drive API.
*/
public function connect()
{
return redirect((new DriveAPI)->authUrl());
}
/**
* Handle the redirect from Google Drive.
*/
public function handle()
{
$client = new DriveAPI();
$token = $client->setToken();
if ($token) {
// Make a word file
$word = new WordCreator([]);
// Create the metadata.
$driveFile = $client->newFile([
'name' => $pitch->name,
'mimeType' => 'application/vnd.google-apps.document',
'parents' => [Session::get('drive_folder')],
]);
// Create a file.
$file = $client->service->files->create($driveFile->getData(), [
'data' => $word->getContent(),
'mimeType' => DOCX,
'uploadType' => 'multipart',
'fields' => 'id',
]);
return redirect('desired-page');
}
// Handle error.
}
许可证
代码在Beerware许可证下发布,尽情享用(眨眼脸)。