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

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nhedger committed Feb 5, 2020
0 parents commit 1446444
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
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
9 changes: 9 additions & 0 deletions .gitattributes
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/vendor/
/composer.lock
21 changes: 21 additions & 0 deletions LICENSE.md
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.
70 changes: 70 additions & 0 deletions README.md
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
36 changes: 36 additions & 0 deletions composer.json
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"
]
}
}
}
14 changes: 14 additions & 0 deletions phpcs.xml
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>
26 changes: 26 additions & 0 deletions src/KDriveServiceProvider.php
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);
});
}
}

0 comments on commit 1446444

Please sign in to comment.