Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit 1446444

Browse files
committed
Initial commit
0 parents  commit 1446444

File tree

8 files changed

+193
-0
lines changed

8 files changed

+193
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all unnecessary files with "export-ignore".
5+
/.editoconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpcs.xml export-ignore
9+
/README.md export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/composer.lock

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) 2020 Nicolas Hedger <[email protected]>
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Laravel kDrive Storage Driver
2+
3+
[![Latest Version on Packagist][icon-version]][link-packagist]
4+
[![Software License][icon-license]](LICENSE.md)
5+
[![Total Downloads][icon-license]][link-packagist]
6+
7+
This package contains an [Infomaniak kDrive](https://www.infomaniak.com/en/kdrive/) storage driver for Laravel.
8+
9+
## Installation
10+
Via [Composer](https://getcomposer.org/)
11+
```shell script
12+
composer require infomaniak/laravel-kdrive
13+
```
14+
15+
### Register the Service Provider
16+
Starting with laravel 5.5, the Service Provider is automatically registered so may skip this instruction.
17+
18+
Add the Service provider to your `config/app.php` file:
19+
20+
```php
21+
'providers' => [
22+
\Infomaniak\KDrive\KDriveServiceProvider::class,
23+
],
24+
```
25+
26+
### Configure a new disk
27+
Add a new disk to your `config/filesystems.php` file:
28+
29+
```php
30+
'disks' => [
31+
'kdrive' => [
32+
'driver' => 'kdrive',
33+
'id' => env('KDRIVE_ID'),
34+
'username' => env('KDRIVE_USERNAME'),
35+
'password' => env('KDRIVE_PASSWORD'),
36+
'prefix' => env('KDRIVE_PREFIX', ''),
37+
]
38+
],
39+
```
40+
41+
### Setup your .env file
42+
Add your credentials to your `.env` file. See [Credentials](#credentials) for more information on obtaining them.
43+
44+
```
45+
KDRIVE_ID=123456
46+
47+
KDRIVE_PASSWORD=********************
48+
KDRIVE_PREFIX=
49+
```
50+
51+
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.
52+
53+
## Credentials
54+
To be able to connect to your kDrive, you'll need the following information.
55+
56+
1. Your kDrive ID ([Find your kDrive ID](#find-your-kdrive-id))
57+
2. Your login email address (the one you'd use on https://manager.infomaniak.com)
58+
3. A unique application password ([Generate an application password](https://manager.infomaniak.com/v3/profile/application-password))
59+
60+
### Find your kDrive ID
61+
1. Connect to your kDrive directly on Infomaniak
62+
2. Find your drive's ID in the URL : `https://drive.infomaniak.com/app/drive/[ID]/files`
63+
64+
## License
65+
The MIT License (MIT). Please see the [LICENSE](LICENSE.md) for more information.
66+
67+
[icon-version]: https://img.shields.io/packagist/v/infomaniak/laravel-kdrive?style=flat-square
68+
[icon-license]: https://img.shields.io/packagist/l/infomaniak/laravel-kdrive?style=flat-square
69+
[icon-downloads]: https://img.shields.io/packagist/dt/infomaniak/laravel-kdrive?style=flat-square
70+
[link-packagist]: https://packagist.org/packages/infomaniak/laravel-kdrive

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "infomaniak/laravel-kdrive",
3+
"description": "Infomaniak kDrive Storage driver for Laravel",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Nicolas Hedger",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"Infomaniak\\KDrive\\": "src/"
15+
}
16+
},
17+
"minimum-stability": "stable",
18+
"require": {
19+
"infomaniak/flysystem-kdrive": "^1.0",
20+
"illuminate/support": "^5.0|^6.0|^7.0"
21+
},
22+
"require-dev": {
23+
"squizlabs/php_codesniffer": "^3.5"
24+
},
25+
"scripts": {
26+
"check-style": "phpcs src",
27+
"fix-style": "phpcbf src"
28+
},
29+
"extra": {
30+
"laravel": {
31+
"providers": [
32+
"Infomaniak\\KDrive\\KDriveServiceProvider"
33+
]
34+
}
35+
}
36+
}

phpcs.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="infomaniak/laravel-kdrive">
3+
<description>The coding standard of infomaniak/laravel-kdrive package</description>
4+
<arg value="p" />
5+
6+
<config name="ignore_warnings_on_exit" value="1" />
7+
<config name="ignore_errors_on_exit" value="1" />
8+
9+
<arg name="colors" />
10+
<arg value="s" />
11+
12+
<!-- Use the PSR2 Standard-->
13+
<rule ref="PSR2" />
14+
</ruleset>

src/KDriveServiceProvider.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Infomaniak\KDrive;
4+
5+
use Illuminate\Support\Facades\Storage;
6+
use Illuminate\Support\ServiceProvider;
7+
use League\Flysystem\Filesystem;
8+
9+
class KDriveServiceProvider extends ServiceProvider
10+
{
11+
/**
12+
* Extend Storage with the kDrive driver.
13+
*/
14+
public function boot()
15+
{
16+
Storage::extend('kdrive', function ($app, $config) {
17+
$kdrive = new KDriveAdapter(
18+
$config['id'],
19+
$config['username'],
20+
$config['password'],
21+
$config['prefix']
22+
);
23+
return new Filesystem($kdrive);
24+
});
25+
}
26+
}

0 commit comments

Comments
 (0)