Flysystem adapter for pCloud with support for Laravel v10+.
A PHP library to access pCloud API
In order to use this package, you have to register your application in My applications.
You can install the package via composer:
composer require lucaf87/flysystem-pcloudor add the following to composer.json file
"require": {
  "lucaf87/flysystem-pcloud": "1.0"
}
Add the following config to the disk array in config/filesystems.php
[
    'pCloud' => [
        'driver' => 'pCloud',
        'clientId' => env('PCLOUD_CLIENT_ID'),
        'clientSecret' => env('PCLOUD_CLIENT_SECRET'),
        'accessToken' => env('PCLOUD_ACCESS_TOKEN'),
        'locationId' => env('PCLOUD_LOCATION_ID'),
    ]
]Then set the FILESYSTEM_DISK to pCloud in your .env
FILESYSTEM_DISK=pCloudPublish configuration file
php artisan vendor:publish --provider="LucaF87\PCloudAdapter\Providers\CustomPCloudServiceProvider" --force
Add the following to your .env
PCLOUD_CLIENT_ID=[Get this from https://docs.pcloud.com/my_apps/]
PCLOUD_CLIENT_SECRET=[Get this from https://docs.pcloud.com/my_apps/]
PCLOUD_ACCESS_TOKEN=[leave blank]
PCLOUD_LOCATION_ID=[leave blank]
PCLOUD_LOCAL_FILE_KEEP_ALIVE=60
php artisan flysystem-pcloud:token
Generate Authorize Code, Navigate to below link (Replace CLIENT_ID with your application Client ID) https://my.pcloud.com/oauth2/authorize?client_id=CLIENT_ID&response_type=code
After you get the access code and the hostname, next step is to generate Access Token. **Before you navigate to below link, make sure to replace Client ID, Secret and Access Code & THE HOST NAME (api.pcloud.com) with what was on the page before https://api.pcloud.com/oauth2_token?client_id=xxxxxxxxx&client_secret=xxxxxxxxx&code=xxxxxxxxx
Copy the access_token and the locationid to the .env 
Storage::disk('pCloud')->putFileAs('files', new File('/tmp/file.txt'), 'file-name.txt');
Storage::disk('pCloud')->exists('/files/file-name.txt'));
$full_path = Storage::disk('pCloud')->get('/files/file-name.txt');Download file in local storage and return the full path
$full_path = Storage::disk('pCloud')->get('/files/file-name.txt');Get a cloud link of a file (It may give problems with different IP addresses)
$url = Storage::disk('pCloud')->fileUrl('/files/file-name.txt'));Download file in local storage and return the content of a file
$contents = Storage::disk('pCloud')->readStream('/files/file-name.txt');Deleting a file:
Storage::disk('pCloud')->delete('/files/file-name.txt');Deleting a directory:
Storage::disk('pCloud')->deleteDirectory('/files'));
Storage::disk('pCloud')->deleteDirectory('/files/test'));Getting the mimetype of a file
$mimeType = Storage::disk('pCloud')->mimeType('/files/file-name.txt');Get the info of a file
$bytes = Storage::disk('pCloud')->fileInfo('/files/file-name.txt');Get a list of files
$files = Storage::disk('pCloud')->files('/files'));Since pCloud needs to download files locally in order to access them, I created a command to delete files from local storage older than 1 hour (parameter customizable from config). You just have to schedule it inside the Console/Kernel.php file
php artisan flysystem-pcloud:clean-local-storagecomposer testThe MIT License (MIT). Please see License File for more information.