This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1446444
Showing
8 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at https://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all unnecessary files with "export-ignore". | ||
/.editoconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/phpcs.xml export-ignore | ||
/README.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/vendor/ | ||
/composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2020 Nicolas Hedger <[email protected]> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Laravel kDrive Storage Driver | ||
|
||
[![Latest Version on Packagist][icon-version]][link-packagist] | ||
[![Software License][icon-license]](LICENSE.md) | ||
[![Total Downloads][icon-license]][link-packagist] | ||
|
||
This package contains an [Infomaniak kDrive](https://www.infomaniak.com/en/kdrive/) storage driver for Laravel. | ||
|
||
## Installation | ||
Via [Composer](https://getcomposer.org/) | ||
```shell script | ||
composer require infomaniak/laravel-kdrive | ||
``` | ||
|
||
### Register the Service Provider | ||
Starting with laravel 5.5, the Service Provider is automatically registered so may skip this instruction. | ||
|
||
Add the Service provider to your `config/app.php` file: | ||
|
||
```php | ||
'providers' => [ | ||
\Infomaniak\KDrive\KDriveServiceProvider::class, | ||
], | ||
``` | ||
|
||
### Configure a new disk | ||
Add a new disk to your `config/filesystems.php` file: | ||
|
||
```php | ||
'disks' => [ | ||
'kdrive' => [ | ||
'driver' => 'kdrive', | ||
'id' => env('KDRIVE_ID'), | ||
'username' => env('KDRIVE_USERNAME'), | ||
'password' => env('KDRIVE_PASSWORD'), | ||
'prefix' => env('KDRIVE_PREFIX', ''), | ||
] | ||
], | ||
``` | ||
|
||
### Setup your .env file | ||
Add your credentials to your `.env` file. See [Credentials](#credentials) for more information on obtaining them. | ||
|
||
``` | ||
KDRIVE_ID=123456 | ||
[email protected] | ||
KDRIVE_PASSWORD=******************** | ||
KDRIVE_PREFIX= | ||
``` | ||
|
||
The `KDRIVE_PREFIX` is optional an you may remove it from you `.env` file is you do not use it. This settings allows you to define another folder as your root. | ||
|
||
## Credentials | ||
To be able to connect to your kDrive, you'll need the following information. | ||
|
||
1. Your kDrive ID ([Find your kDrive ID](#find-your-kdrive-id)) | ||
2. Your login email address (the one you'd use on https://manager.infomaniak.com) | ||
3. A unique application password ([Generate an application password](https://manager.infomaniak.com/v3/profile/application-password)) | ||
|
||
### Find your kDrive ID | ||
1. Connect to your kDrive directly on Infomaniak | ||
2. Find your drive's ID in the URL : `https://drive.infomaniak.com/app/drive/[ID]/files` | ||
|
||
## License | ||
The MIT License (MIT). Please see the [LICENSE](LICENSE.md) for more information. | ||
|
||
[icon-version]: https://img.shields.io/packagist/v/infomaniak/laravel-kdrive?style=flat-square | ||
[icon-license]: https://img.shields.io/packagist/l/infomaniak/laravel-kdrive?style=flat-square | ||
[icon-downloads]: https://img.shields.io/packagist/dt/infomaniak/laravel-kdrive?style=flat-square | ||
[link-packagist]: https://packagist.org/packages/infomaniak/laravel-kdrive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "infomaniak/laravel-kdrive", | ||
"description": "Infomaniak kDrive Storage driver for Laravel", | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Nicolas Hedger", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Infomaniak\\KDrive\\": "src/" | ||
} | ||
}, | ||
"minimum-stability": "stable", | ||
"require": { | ||
"infomaniak/flysystem-kdrive": "^1.0", | ||
"illuminate/support": "^5.0|^6.0|^7.0" | ||
}, | ||
"require-dev": { | ||
"squizlabs/php_codesniffer": "^3.5" | ||
}, | ||
"scripts": { | ||
"check-style": "phpcs src", | ||
"fix-style": "phpcbf src" | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Infomaniak\\KDrive\\KDriveServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="infomaniak/laravel-kdrive"> | ||
<description>The coding standard of infomaniak/laravel-kdrive package</description> | ||
<arg value="p" /> | ||
|
||
<config name="ignore_warnings_on_exit" value="1" /> | ||
<config name="ignore_errors_on_exit" value="1" /> | ||
|
||
<arg name="colors" /> | ||
<arg value="s" /> | ||
|
||
<!-- Use the PSR2 Standard--> | ||
<rule ref="PSR2" /> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Infomaniak\KDrive; | ||
|
||
use Illuminate\Support\Facades\Storage; | ||
use Illuminate\Support\ServiceProvider; | ||
use League\Flysystem\Filesystem; | ||
|
||
class KDriveServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Extend Storage with the kDrive driver. | ||
*/ | ||
public function boot() | ||
{ | ||
Storage::extend('kdrive', function ($app, $config) { | ||
$kdrive = new KDriveAdapter( | ||
$config['id'], | ||
$config['username'], | ||
$config['password'], | ||
$config['prefix'] | ||
); | ||
return new Filesystem($kdrive); | ||
}); | ||
} | ||
} |