thomasvantuycom/flysystem-cloudinary 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

thomasvantuycom/flysystem-cloudinary

最新稳定版本:v2.0.2

Composer 安装命令:

composer require thomasvantuycom/flysystem-cloudinary

包简介

Cloudinary filesystem adapter for Flysystem.

README 文档

README

This is a Flysystem adapter for Cloudinary. Although not the first of its kind, this package strives to be the ultimate and dependable Flysystem adapter for Cloudinary.

Installation

composer require thomasvantuycom/flysystem-cloudinary

Usage

Configure a Cloudinary client by supplying the cloud name, API key, and API secret accessible in the Cloudinary console. Then, pass the client to the adapter and initialize a new filesystem using the adapter.

use Cloudinary\Cloudinary;
use League\Flysystem\Filesystem;
use ThomasVantuycom\FlysystemCloudinary\CloudinaryAdapter;

$client = new Cloudinary([
    'cloud' => [
        'cloud_name' => 'CLOUD_NAME',
        'api_key' => 'API_KEY',
        'api_secret' => 'API_SECRET',
    ],
]);

$adapter = new CloudinaryAdapter($client);

$filesystem = new Filesystem($adapter);

Storing assets in a subfolder

By default, the root folder of the filesystem corresponds to Cloudinary's root folder. If you prefer to store your assets in a subfolder on Cloudinary, you can create a path-prefixed adapter.

use League\Flysystem\PathPrefixng\PathPrefixedAdapter;

$adapter = new CloudinaryAdapter($client, 'path/to/folder');
$pathPrefixedAdapter = new PathPrefixedAdapter($adapter, 'path/to/folder');

Customizing mime type detection

By default, the adapter employs League\MimeTypeDetection\FinfoMimeTypeDetector for mime type detection and setting the resource type accordingly. If you wish to modify this behavior, you can supply a second argument to the Cloudinary adapter, implementing League\MimeTypeDetection\MimeTypeDetector.

$adapter = new CloudinaryAdapter($client, $mimeTypeDetector);

Enabling fixed folder mode.

By default, the adapter operates under the assumption that your Cloudinary cloud uses dynamic folder mode. If you wish to support the legacy fixed folder mode, set the third argument to false.

$adapter = new CloudinaryAdapter($client, null, true);

Limitations

  • The adapter heavily relies on the Cloudinary admin API to implement most of Flysystem's operations. Because the admin API has rate limits, you may run into timeouts. The Cloudinary API poses challenges in how it distinguishes between images, videos, and other assets, making the task of ensuring seamless operation across all file types quite intricate and expensive in API calls. It's important to highlight that deleting folders can be particularly resource-intensive.
  • The adapter is compatible with Cloudinary's dynamic folders mode. However, it operates on the assumption that the public IDs of your assets do not include a path.

Testing

composer test

License

The MIT License.

统计信息

  • 总下载量: 14.78k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-25