承接 lucaf87/flysystem-pcloud 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lucaf87/flysystem-pcloud

最新稳定版本:1.0.8

Composer 安装命令:

composer create-project lucaf87/flysystem-pcloud

包简介

README 文档

README

Latest Version on Packagist Total Downloads

Flysystem adapter for pCloud with support for Laravel v10+.

A PHP library to access pCloud API

Get started

Register your application

In order to use this package, you have to register your application in My applications.

Installation

You can install the package via composer:

composer require lucaf87/flysystem-pcloud

or 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=pCloud

Publish 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

Generate Auth

Artisan

php artisan flysystem-pcloud:token

Manual

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 

Example

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'));

Clean local storage

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-storage

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 434
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-07