Coder Social home page Coder Social logo

fawzanm / flysystem-google-drive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from private-it/flysystem-google-drive

0.0 2.0 0.0 11 KB

FlySystem adapter for Google Drive (work with path) use with laravel Storage interface

License: MIT License

PHP 100.00%

flysystem-google-drive's Introduction

flysystem-google-drive

FlySystem adapter for Google Drive (work with path)

This project is wrapper of nao-pon/flysystem-google-drive

Read more information this

Installation

composer require private-it/flysystem-google-drive:dev-master

Config

Config params:

[
    'clientId' => 'xxxxxxxxxxx.apps.googleusercontent.com',
    'clientSecret' => 'xxxxxxxxxxx',
    'refreshToken' => 'xxxxxxxxxxx',
    'folderId' => 'xxxxxxxxxxx',
    'sheetId' => 'xxxxxxxxxxx',
];

folderId - uses as root folder for upload/read.

sheetId - file id of "Google Sheets" document. Uses for save path-fileId. This document must be shared for public read.

Usage example

See examples/test.php

git clone https://github.com/private-it/flysystem-google-drive.git
composer install

Copy examples/config.example.php to examples/config.php

php examples/test.php

Usage with Laravel

Configuration google drive config/filesystems.php

    'disks' => [
...
        'googleDrive' => [
            'driver' => 'googleDrive',
            'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
            'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
            'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
            'folderId' => env('GOOGLE_DRIVE_FOLDER_ID'),
            'sheetId' => env('GOOGLE_DRIVE_PATH_MANAGER_SHEET_ID'),
        ],
...
    ],

[Laravel v4] Add ServiceProvider to config/app.php

'providers' => [
    ...
    PrivateIT\FlySystem\GoogleDrive\GoogleDriveServiceProvider::class
    ...
]

For custom PathManager you can set binding in file bootstrap/app.php

$app->bind(\PrivateIT\FlySystem\GoogleDrive\PathManager::class, \PrivateIT\FlySystem\GoogleDrive\GoogleSheetsPathManager::class);

Usage:

$disk = \Storage::disk('googleDrive');
$adapter = $disk->getDriver()->getAdapter();

$dir = 'test/sub1/sub2';
$fileName = 'test/sub1/sub2/new-file-1.txt';

var_dump($disk->makeDirectory($dir));
var_dump($disk->put($fileName, 'test content'));
var_dump($adapter->getUrl($fileName));
var_dump($disk->deleteDir($dir));

flysystem-google-drive's People

Contributors

rendol avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.